Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created May 15, 2020 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencurtis/e66e0c4694576c49e9c3b59e4cdac5fd to your computer and use it in GitHub Desktop.
Save stevencurtis/e66e0c4694576c49e9c3b59e4cdac5fd to your computer and use it in GitHub Desktop.
handlePan
@objc func handlePan(_ sender: UIPanGestureRecognizer) {
let targetView = sender.view!
let translation = sender.translation(in: view)
switch sender.state {
case .began,.changed, .ended:
targetView.center = CGPoint(x: targetView.center.x + translation.x
,y: targetView.center.y + translation.y)
sender.setTranslation(CGPoint.zero, in: view)
break
default:
break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment