Skip to content

Instantly share code, notes, and snippets.

@victorBaro
Created September 1, 2018 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorBaro/3d5d3d544eab3596ba02d2cd7cf15b60 to your computer and use it in GitHub Desktop.
Save victorBaro/3d5d3d544eab3596ba02d2cd7cf15b60 to your computer and use it in GitHub Desktop.
Control magnifying glass view from another view
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