Skip to content

Instantly share code, notes, and snippets.

@hyukhur
Created October 23, 2017 03:02
Show Gist options
  • Save hyukhur/339d582df0fea551613e3fc8e986bd0e to your computer and use it in GitHub Desktop.
Save hyukhur/339d582df0fea551613e3fc8e986bd0e to your computer and use it in GitHub Desktop.
Sugary Button. - its appearance could be disable but be able to be tapped to show alert view.
// its appearance could be disable but be able to be tapped to show alert view.
private extension UIControlState {
private static let localScope = UIControlState.application.rawValue | 0x0000FF00
static var normalState = UIControlState(rawValue: localScope | 1 << 1)
static var blockingState = UIControlState(rawValue: localScope | 1 << 2)
}
extension UIButton {
var isBlocked: Bool = false {
didSet {
if isBlocked {
setImage(image(for: .blockingState), for: .normal)
}
else {
setImage(image(for: .normalState), for: .normal)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment