Guest User

Untitled

a guest
Jun 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. ypealias DidTapButton = (MyButton) -> ()
  2.  
  3. var didTouchUpInside: DidTapButton? {
  4. didSet {
  5. if didTouchUpInside != nil {
  6. addTarget(self, action: #selector(didTouchUpInside(_:)), forControlEvents: .TouchUpInside)
  7. } else {
  8. removeTarget(self, action: #selector(didTouchUpInside(_:)), forControlEvents: .TouchUpInside)
  9. }
  10. }
  11. }
  12.  
  13. // MARK: - Actions
  14.  
  15. func didTouchUpInside(sender: MyButton) {
  16. if let handler = didTouchUpInside {
  17. handler(self)
  18. }
  19. }
Add Comment
Please, Sign In to add comment