Created
October 29, 2017 14:45
-
-
Save nathangitter/3f2cf65a0c589ebe4ac556b9d9de7037 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyButton: UIButton { | |
var action: (() -> ())? | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
sharedInit() | |
} | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
sharedInit() | |
} | |
private func sharedInit() { | |
addTarget(self, action: #selector(touchUpInside), for: .touchUpInside) | |
} | |
@objc private func touchUpInside() { | |
action?() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment