storyboardのconstrainのerror解消がわからず、時間がかかりましたが、
@IBAction func getGoo(_ sender: Any) { let results1 = ["Image1","Image2","Image3"] let random1 = arc4random_uniform(UInt32(results1.count)) let image1 = UIImage(named: results1[Int(random1)]) imageView.image = image1 let image4 = UIImage(named: "Image4") imageView2.image = image4 } @IBAction func getChoki(_ sender: Any) { let results2 = ["Image1","Image2","Image3"] let random2 = arc4random_uniform(UInt32(results2.count)) let image2 = UIImage(named: results2[Int(random2)]) imageView.image = image2 let image5 = UIImage(named: "Image5") imageView2.image = image5 } @IBAction func getPa(_ sender: Any) { let results3 = ["Image1","Image2","Image3"] let random3 = arc4random_uniform(UInt32(results3.count)) let image3 = UIImage(named: results3[Int(random3)]) imageView.image = image3 let image6 = UIImage(named: "Image6") imageView2.image = image6 } override func viewDidLoad() { super.viewDidLoad() imageView.contentMode = UIViewContentMode.center self.view.addSubview(imageView) imageView2.contentMode = UIViewContentMode.center self.view.addSubview(imageView2) // Do any additional setup after loading the view, typically from a nib. }
O~K~! 選択したグーチョキパーとランダムのグーチョキパーを表示します。
勝ちか負けかをテキストで表示したい
可能であれば、何連勝とかも。。できるのか?