Skip to content

Instantly share code, notes, and snippets.

@rawnly
Created November 9, 2018 21:01
Show Gist options
  • Save rawnly/1d15a58020958789ef267f1daadd5072 to your computer and use it in GitHub Desktop.
Save rawnly/1d15a58020958789ef267f1daadd5072 to your computer and use it in GitHub Desktop.
// ... ViewController
// Let's start
override func viewDidLoad() {
super.viewDidLoad()
// Do not forget to enable user interaction on our imageView
imageView.isUserInteractionEnabled = true
let pinch = UIPinchGestureRecognizer(target: self, action: #selector(handlePinchGesture))
let pan = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture))
// Use 2 thingers to move the view
pan.minimumNumberOfTouches = 2
pan.maximumNumberOfTouches = 2
// We delegate gestures so we can
// perform both at the same time
pan.delegate = self
pinch.delegate = self
// Add the gestures to our target (imageView)
imageView.addGestureRecognizer(pinch)
imageView.addGestureRecognizer(pan)
// Here some basic setup
view.addSubView(overlay)
view.bringSubViewToFront(imageView)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment