Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding UIBUTTON swift

Tags:

swift

uibutton

In swift, how do I hide a UIButton?

Here's what I tried: button.enabled = false

However, that just greys out the button, not making it invisible.

Is there a way to do it in swift? If so, how?

Thanks!

like image 805
rocket101 Avatar asked Dec 26 '14 01:12

rocket101


People also ask

What is a hidden view?

A hidden view disappears from its window and does not receive input events. It remains in its superview's list of subviews, however, and participates in autoresizing as usual. Hiding a view with subviews has the effect of hiding those subviews and any view descendants they might have.


2 Answers

Umm… button.hidden = true. See UIView Class Reference.

Be sure to look at methods available in parent classes when reading the documentation for a class.


NOTE: A later version of swift enforced button.isHidden = true as the only option.

like image 136
Jeffery Thomas Avatar answered Nov 12 '22 14:11

Jeffery Thomas


For iOS 8+

button.isHidden = true

Apple Documentation

like image 32
bob.faist Avatar answered Nov 12 '22 15:11

bob.faist