Created
September 1, 2018 22:40
-
-
Save victorBaro/3d5d3d544eab3596ba02d2cd7cf15b60 to your computer and use it in GitHub Desktop.
Control magnifying glass view from another view
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
class ViewController: UIViewController { | |
//Set your views and long press recognizer to magnifyControlView | |
private func handleMagnify(_ recognizer: UILongPressGestureRecognizer) { | |
let point = recognizer.location(in: magnifyControlView).multiplyValues(by: controlScale) | |
switch recognizer.state { | |
case .began: | |
magnifyView = MagnifyingView(viewToMagnify: comicPageImageView, size: CGSize(width: 200, height: 200)) | |
magnifyView.setTouchPoint(point) | |
self.addSubview(magnifyView) | |
case .changed: | |
magnifyView.setTouchPoint(point) | |
case .cancelled, .ended, .failed: | |
magnifyView.removeFromSuperview() | |
magnifyView = nil | |
default: return | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment