Skip to content

Instantly share code, notes, and snippets.

@maml
Created September 8, 2015 18:11
Show Gist options
  • Save maml/aedec4f7ca9b35e2792d to your computer and use it in GitHub Desktop.
Save maml/aedec4f7ca9b35e2792d to your computer and use it in GitHub Desktop.
Adds some helper methods to UIButton for enabling, disabling, hiding, showing, and combinations thereof.
import UIKit
extension UIButton {
func disable() {
self.enabled = false
}
func enable() {
self.enabled = true
}
func hide() {
self.hidden = true
}
func show() {
self.hidden = false
}
func disableAndHide() {
self.disable()
self.hide()
}
func disableAndShow() {
self.disable()
self.show()
}
func enableAndHide() {
self.enable()
self.hide()
}
func enableAndShow() {
self.enable()
self.show()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment