Skip to content

Instantly share code, notes, and snippets.

@slav123
Created June 17, 2015 23:47
Show Gist options
  • Save slav123/2fd6a3d1ce6dea0d9660 to your computer and use it in GitHub Desktop.
Save slav123/2fd6a3d1ce6dea0d9660 to your computer and use it in GitHub Desktop.
gesture recognizzers
override func viewDidLoad() {
super.viewDidLoad()
var swipeRight = UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeRight.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(swipeRight)
var swipeDown = UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeDown.direction = UISwipeGestureRecognizerDirection.Down
self.view.addGestureRecognizer(swipeDown)
}
func respondToSwipeGesture(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizerDirection.Right:
println("Swiped right")
case UISwipeGestureRecognizerDirection.Down:
println("Swiped down")
default:
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment