baranbaris baranbaris - 1 month ago 13
Swift Question

Disable a Button

I want to disable a button (

UIButton
) 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

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.