views:

158

answers:

3

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

A: 

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.

Vladimir
+1  A: 
myButton.highlighted = YES/NO;
myButton.selected = YES/NO;
myButton.enabled = YES/NO;

These are defined on UIButton's ancestor UIControl.

Felixyz
A: 

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.

samwize