Large Image VC: Don't let image overlap top controls when zoomed out
This commit is contained in:
parent
ea143ea0dd
commit
bd8e16cacb
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue