更改IBOutletCollection中的UIButton的背景颜色

问题描述 投票:-6回答:1

我有16个按钮。当单击按钮时,我想更改按钮的背景颜色。

这是我的代码:

@IBOutlet var buttons: [UIButton]!

@IBAction func button_Taped(_ sender: UIButton) {  

    }
}

单击按钮时如何更改按钮的背景色

ios swift background-color iboutlet iboutletcollection
1个回答
0
投票
@IBOutlet var buttons: [UIButton]!

@IBAction func button_Taped(_ sender: UIButton) {  
sender.backgroundColor = // your desired color
    }
}
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.