Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually setting a UIButton state

Tags:

I UIButton using + buttonWithType:

What I need to figure out is how to manually change the button state. There are times when I need it to be set to "disabled."

I read through the UIButton documentation but I cannot seem to find anything about manually setting a button state.

Any thoughts would be greatly appreciated.

like image 724
acreek Avatar asked Jan 01 '09 16:01

acreek


2 Answers

Did you try button.enabled = NO;?

Swift 5.0

button.isEnabled = false
like image 82
Ben Gottlieb Avatar answered Oct 23 '22 04:10

Ben Gottlieb


there are also the states:

   button.highlighted = NO;
   button.selected = NO;
like image 23
roberthuttinger Avatar answered Oct 23 '22 04:10

roberthuttinger