From bd8e16cacbb6d26e459d30d05e343743db392522 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 14 Jun 2019 15:27:17 -0700 Subject: [PATCH] Large Image VC: Don't let image overlap top controls when zoomed out --- Tusker/Screens/Large Image/LargeImageViewController.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Large Image/LargeImageViewController.swift b/Tusker/Screens/Large Image/LargeImageViewController.swift index 7661a6bf..e8ad7956 100644 --- a/Tusker/Screens/Large Image/LargeImageViewController.swift +++ b/Tusker/Screens/Large Image/LargeImageViewController.swift @@ -118,8 +118,11 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate { override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() - let widthScale = view.bounds.size.width / imageView.bounds.width - let heightScale = view.bounds.size.height / imageView.bounds.height + // limit the image height to the safe area height, so the image doesn't overlap the top controls + // while zoomed all the way out + let maxHeight = view.bounds.height - view.safeAreaInsets.top - view.safeAreaInsets.bottom + let heightScale = maxHeight / imageView.bounds.height + let widthScale = view.bounds.width / imageView.bounds.width let minScale = min(widthScale, heightScale) scrollView.minimumZoomScale = minScale scrollView.zoomScale = minScale