ボタン1、2、3、4、5を作成しました。
5のボタンはある条件を満たしたときに表示したいため
@IBOutlet weak var button5: UIButton override func viewDidLoad() { super.viewDidLoad() button5.isHidden = true
として非表示にしています。
その条件とは、ボタン1,2,3,4のいずれか2つのボタンのbackgroundColorがblueになった時に表示したいということです。
1、2、3、4のボタンのbackgroundColorの変化までは実装済みなのですがそこからどうやればいいのか全くわかりません。
ご指導お願いします。。。> 引用テキスト
現状
import
1 2class kamotsuViewController: UIViewController { 3 4 @IBOutlet weak var button1: UIButton! 5 @IBOutlet weak var button2: UIButton! 6 @IBOutlet weak var button3: UIButton! 7 @IBOutlet weak var button4: UIButton! 8 var count = 1 9 10 @IBOutlet weak var button5: UIButton! 11 override func viewDidLoad() { 12 super.viewDidLoad() 13 button5.isHidden = true 14 15 } 16 @IBAction func button1(_ sender: UIButton) { 17 count += 1 18 if(count%2 == 0){sender.backgroundColor = UIColor.blue 19 } 20 else{sender.backgroundColor = UIColor.white} 21 22 } 23 @IBAction func button2(_ sender: UIButton) { 24 count += 1 25 if(count%2 == 0){sender.backgroundColor = UIColor.blue 26 } 27 else{sender.backgroundColor = UIColor.white} 28 } 29 @IBAction func button3(_ sender: UIButton) { 30 count += 1 31 if(count%2 == 0){sender.backgroundColor = UIColor.blue 32 } 33 else{sender.backgroundColor = UIColor.white} 34 } 35 @IBAction func button4(_ sender: UIButton) { 36 count += 1 37 if(count%2 == 0){sender.backgroundColor = UIColor.blue 38 } 39 else{sender.backgroundColor = UIColor.white} 40 41 } 42 43 44 45 46 }
回答1件
あなたの回答
tips
プレビュー