Skip to content

Instantly share code, notes, and snippets.

@cjinghong
Last active November 13, 2017 08:10
Show Gist options
  • Save cjinghong/943891a5605bab6320abd6eccd02aae8 to your computer and use it in GitHub Desktop.
Save cjinghong/943891a5605bab6320abd6eccd02aae8 to your computer and use it in GitHub Desktop.
@objc func handlePan(_ gesture: UIPanGestureRecognizer) {
let location = gesture.location(in: self.view)
// To figure out the fraction completed, take the x location of the touch,
// and divide it by the maximum x the finger can move to (which is the screen's width)
let fractionCompleted = location.x / self.view.bounds.width
// Changing this property changes the % complete of the animation.
// Try experimenting with a different fraction and see what you get
animator.fractionComplete = fractionCompleted
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment