-1
我已編程方式創建按鈕,想改變顏色,當按鈕點擊,例如,如果一個按鈕,點擊改變顏色爲紅色,另一個按鈕點擊方式改回默認如何改變動態按鈕的背景顏色
我創建使用
for var i=0 ;i<=8;i++{
var button = UIButton(..)
........... blah blah......
button.addTarget(..,action:"buttonsClick",...)
}
fun buttonsClick(sender:UIButton){
// here how to identify which button is clicked and change color to red if another is clicked means change to default color
var tagnum = sender.tag
}
可用
或者另一種解決方案這個