单击和关闭时更改按钮的颜色

时间:2017-08-18 09:58:28

标签: ios swift3 ibaction

enter image description here

每次用户点击上述任何一个按钮时,都会显示一个新的视图控制器,我还有一个绿色图标和一个黑色图标。我需要的功能是点击任何这些按钮将使其他按钮变黑,而点击的按钮将变成青色。我不知道我该怎么做。按钮是否有任何代表被调用或什么。请建议我正确的方法。

1 个答案:

答案 0 :(得分:0)

Attribute Inspector中设置所选图像并取消选择图像。

enter image description here enter image description here

然后将属性设置为UIButton

selectedButton.isSelected = true
normalButton.isSelected = false