Skip to content

Instantly share code, notes, and snippets.

@fl034
fl034 / doubleTapZoom
Last active March 4, 2025 10:32 — forked from gunantosteven/doubleTapZoom
Double Tap Zoom to The Tap Location Swift 5 iOS 13
@objc func handleDoubleTap(_ recognizer: UITapGestureRecognizer) {
let scale = min(scrollView.zoomScale * 2, scrollView.maximumZoomScale)
if scrollView.zoomScale == scrollView.minimumZoomScale { // zoom in
let point = recognizer.location(in: imageView)
let scrollSize = scrollView.frame.size
let zoomScale = scrollView.maximumZoomScale * 0.7
let size = CGSize(width: scrollSize.width / zoomScale,
height: scrollSize.height / zoomScale)
@gunantosteven
gunantosteven / doubleTapZoom
Last active March 4, 2025 10:32
Double Tap Zoom to The Tap Location Swift 5 iOS 13
@objc func handleDoubleTap(_ recognizer: UITapGestureRecognizer) {
let scale = min(scrollView.zoomScale * 2, scrollView.maximumZoomScale)
if scale != scrollView.zoomScale { // zoom in
let point = recognizer.location(in: imageView)
let scrollSize = scrollView.frame.size
let size = CGSize(width: scrollSize.width / scrollView.maximumZoomScale,
height: scrollSize.height / scrollView.maximumZoomScale)
let origin = CGPoint(x: point.x - size.width / 2,