baranbaris baranbaris - 1 year ago 151
Swift Question

Disable a Button

I want to disable a button (

) on iOS after it is clicked. I am new to developing for iOS but I think the equivalent code on objective - C is this:

button.enabled = NO;

But I couldn't do that on swift.

Answer Source

The boolean value for NO in Swift is false.

button.isEnabled = false

should do it.

Here is the Swift documentation for UIControl's isEnabled property.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download