Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override func viewDidLoad() {
- super.viewDidLoad()
- addPanGesture()
- }
- func addPanGesture(){
- let panGesture = UIPanGestureRecognizer(target: self, action: #selector(didSwipeOnView(gesture:)))
- self.view.addGestureRecognizer(panGesture)
- }
- @objc func didSwipeOnView(gesture: UIPanGestureRecognizer) {
- if gesture.state == .ended {
- let velocity = gesture.velocity(in: self.view)
- if velocity.x > 0 {
- print("panning right")
- } else if velocity.x < 0 {
- print("panning left")
- }
- }
- }
Add Comment
Please, Sign In to add comment