Created
May 15, 2020 17:47
-
-
Save stevencurtis/e66e0c4694576c49e9c3b59e4cdac5fd to your computer and use it in GitHub Desktop.
handlePan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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