Skip to content

Instantly share code, notes, and snippets.

@jscalo
Created December 18, 2020 18:20
Show Gist options
  • Save jscalo/f1e59265b3b25d380763d1fd09f759af to your computer and use it in GitHub Desktop.
Save jscalo/f1e59265b3b25d380763d1fd09f759af to your computer and use it in GitHub Desktop.
@objc func pinchGesture(_ gc: UIPinchGestureRecognizer) {
switch gc.state {
case .changed:
pauseUpdates = true
scrollView.recenterForScale(gc.scale)
pauseUpdates = false
let newScale = viewPort.zoom * gc.scale
viewPort.zoom = max(newScale, 1.0)
gc.scale = 1.0
case .ended, .cancelled, .failed:
break
default: break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment