Created
November 9, 2018 21:01
-
-
Save rawnly/1d15a58020958789ef267f1daadd5072 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ... 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