Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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