开发者

UIButton State (UIControlState)

开发者 https://www.devze.com 2023-01-12 14:19 出处:网络
How do I set the state of of UIButton ? In the UIButton class reference there is a \"state\" 开发者_开发问答but it is only \"readonly\".

How do I set the state of of UIButton ?

In the UIButton class reference there is a "state" 开发者_开发问答but it is only "readonly".

Thanks James


You can set selected property for example

buttton.selected = YES;

Also enabled and highlighted properties are available.

Note that all these properties set a bit mask on control's state which you can get using read-only state property.


myButton.highlighted = YES/NO;
myButton.selected = YES/NO;
myButton.enabled = YES/NO;

These are defined on UIButton's ancestor UIControl.


The above 2 replies are quite the answers.

It is to be noted that you cannot change state of a UIButton directly. The state is changed indirectly by other event triggers.

0

精彩评论

暂无评论...
验证码 换一张
取 消