perlguy2

Tap Gesture Programmatically

Jun 29th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.33 KB | None | 0 0
  1. let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
  2.  
  3. view.addGestureRecognizer(tap)
  4.  
  5. view.isUserInteractionEnabled = true
  6.  
  7. self.view.addSubview(view)
  8.  
  9. // function which is triggered when handleTap is called
  10. @objc func handleTap(_ sender: UITapGestureRecognizer) {
  11.     print("Hello World")
  12. }
Advertisement
Add Comment
Please, Sign In to add comment