简体   繁体   English

以编程方式更改UIButton状态

[英]Change UIButton state programmatically

I am trying to change a UIButton's state programmatically, so that when i tap it, the background stays blue. 我试图以编程方式更改UIButton的状态,这样当我点击它时,背景保持蓝色。 I can change the enabled property and that works, but changing selected or highlighted doesnt affect the state. 我可以更改启用的属性,但是有效,但更改选定或突出显示不会影响状态。

Is this possible? 这可能吗?

Thanks 谢谢

您可以随时使用ivar独立于按钮跟踪您自己的状态,然后更改按钮的背景以适应状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM