Guest User

Untitled

a guest
Feb 19th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. override func viewDidLoad() {
  2. super.viewDidLoad()
  3. addPanGesture()
  4. }
  5.  
  6. func addPanGesture(){
  7. let panGesture = UIPanGestureRecognizer(target: self, action: #selector(didSwipeOnView(gesture:)))
  8. self.view.addGestureRecognizer(panGesture)
  9. }
  10.  
  11. @objc func didSwipeOnView(gesture: UIPanGestureRecognizer) {
  12. if gesture.state == .ended {
  13. let velocity = gesture.velocity(in: self.view)
  14.  
  15. if velocity.x > 0 {
  16. print("panning right")
  17.  
  18. } else if velocity.x < 0 {
  19. print("panning left")
  20.  
  21. }
  22. }
  23. }
Add Comment
Please, Sign In to add comment