2017-08-05 4 views
0

ボタンを押したときに背景の「+」、「 - 」、「/」、「*」が灰色に変わるようにするにはどうすればいいですか?ボタンを押したとき(クリアと等しい)、ボタンの背景を「+」、「 - 」、「/」、「*」に変更します。 (IOS)

enter image description here

@IBAction func AnAnimate(_ sender: UIButton) { 

    if sender.currentBackgroundImage == #imageLiteral(resourceName: "image_off") { 
     sender.setBackgroundImage(#imageLiteral(resourceName: "Image_on"), for: .normal) 
    } else { 
     sender.setBackgroundImage(#imageLiteral(resourceName: "image_off"), for: .normal) 
    } 
    if (previousButton !== sender) { 
     previousButton.setBackgroundImage(#imageLiteral(resourceName: "image_off"), for: .normal) 

     previousButton = sender 
    } 
} 

答えて

1

buttonは、そのようなすべてのあなたのbuttonbackground色を変更押されたときにそう、その後buttonoutletを持っていると仮定。

button1.backgroundColor = UIColor.gray 
button2.backgroundColor = UIColor.gray 
関連する問題