Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 630
baranbaris Avatar asked Aug 27 '14 10:08

baranbaris


People also ask

How do I make button disabled?

The disabled attribute is a boolean attribute. When present, it specifies that the button should be disabled. A disabled button is unusable and un-clickable. The disabled attribute can be set to keep a user from clicking on the button until some other condition has been met (like selecting a checkbox, etc.).

Can you disable a button using CSS?

Pure CSS Disabled Button is used to create a disabled button. To make the disabled button, we will use the Pure CSS class “pure-button-disabled” with the class “pure-button”. We can also create a disabled button using disabled attribute.

How do I disable a button in Chrome?

Here's all you need to do to remove the Apps button. First, open the Chrome Browser on your Windows, Mac, or Linux computer. Next, right-click anywhere on the Bookmarks Bar or the “Apps” button itself. This will open a menu, from which you should unselect “Show Apps Shortcut.”


1 Answers

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.

like image 146
KerrM Avatar answered Oct 14 '22 06:10

KerrM