ios - 更改 IBOutletCollection 中 UIButton 的背景颜色
问题描述
我有 16 个按钮。我想在单击按钮时更改按钮的背景颜色。
这是我的代码:
@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
}
}
推荐阅读
- apache-flink - Apache Flink:即使没有输入记录到达给定窗口,也会定期发出输出记录
- javascript - React - 如何修复非常不一致的禁用按钮倒计时(即整秒)
- python - PyYaml 中的缩进值
- group-by - 在分组的小标题中查找匹配元素的数量
- javascript - 如何在 Django 项目中访问 Javascript 中的媒体文件?
- swift - 试图在 Swift 中的框架和应用程序之间实现 Google Sign?
- r - 在这种情况下,如何获得闪亮的文本输出?
- git - TortoiseGit 日志 - 我可以只查看分支和合并提交吗?
- javascript - 在 Azure 上作为静态应用托管的 Create-react-app 未检测到环境变量
- python - Flask ModelView 未显示在头栏中