Ios 更改iOutletCollection中UIButton的背景色
我有16个按钮。我想改变按钮的背景色,当按钮被点击时 这是我的代码:Ios 更改iOutletCollection中UIButton的背景色,ios,swift,background-color,iboutlet,iboutletcollection,Ios,Swift,Background Color,Iboutlet,Iboutletcollection,我有16个按钮。我想改变按钮的背景色,当按钮被点击时 这是我的代码: @IBOutlet var buttons: [UIButton]! @IBAction func button_Taped(_ sender: UIButton) { } } 单击“更改发件人背景色”按钮时,我如何更改?请不要仅将代码作为答案发布,还要说明代码的作用以及如何解决问题。带有解释的答案通常质量更高,更容易吸引选票。 @IBOutlet var buttons: [UIButton]! @IBA
@IBOutlet var buttons: [UIButton]!
@IBAction func button_Taped(_ sender: UIButton) {
}
}
单击“更改发件人背景色”按钮时,我如何更改?请不要仅将代码作为答案发布,还要说明代码的作用以及如何解决问题。带有解释的答案通常质量更高,更容易吸引选票。
@IBOutlet var buttons: [UIButton]!
@IBAction func button_Taped(_ sender: UIButton) {
sender.backgroundColor = // your desired color
}
}