From e837a4dc4e03331197cfbd4dd20bf2b0950cc6a6 Mon Sep 17 00:00:00 2001 From: PJ Gray Date: Mon, 4 Jan 2016 19:56:46 -0500 Subject: [PATCH] Fixes suzuki-0000/SKPhotoBrowser#8 - Double tapping scaled UIImage --- SKPhotoBrowser/SKZoomingScrollView.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/SKPhotoBrowser/SKZoomingScrollView.swift b/SKPhotoBrowser/SKZoomingScrollView.swift index 3d6c265..2b84277 100644 --- a/SKPhotoBrowser/SKZoomingScrollView.swift +++ b/SKPhotoBrowser/SKZoomingScrollView.swift @@ -196,9 +196,15 @@ public class SKZoomingScrollView:UIScrollView, UIScrollViewDelegate, SKDetecting } public func zoomRectForScrollView(withScale:CGFloat, touchPoint:CGPoint) -> CGRect{ - return CGRectMake(touchPoint.x - (frame.size.width / 2.0), - touchPoint.y - (frame.size.height / 2.0), - frame.size.width, frame.size.height) + if let imageScale = photoImageView.image?.scale { + return CGRectMake(touchPoint.x - ((frame.size.width * imageScale) / 2.0), + touchPoint.y - ((frame.size.height * imageScale) / 2.0), + frame.size.width, frame.size.height) + } else { + return CGRectMake(touchPoint.x - (frame.size.width / 2.0), + touchPoint.y - (frame.size.height / 2.0), + frame.size.width, frame.size.height) + } } // MARK: - UIScrollViewDelegate