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!
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.
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.
For iOS 8+
button.isHidden = true
Apple Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With