Ios – Manually setting a UIButton state

cocoa-touchiosiphoneobjective cuibutton

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.

Best Answer

Did you try button.enabled = NO;?

Swift 5.0

button.isEnabled = false