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() {
|
override func viewDidLayoutSubviews() {
|
||||||
super.viewDidLayoutSubviews()
|
super.viewDidLayoutSubviews()
|
||||||
|
|
||||||
let widthScale = view.bounds.size.width / imageView.bounds.width
|
// limit the image height to the safe area height, so the image doesn't overlap the top controls
|
||||||
let heightScale = view.bounds.size.height / imageView.bounds.height
|
// 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)
|
let minScale = min(widthScale, heightScale)
|
||||||
scrollView.minimumZoomScale = minScale
|
scrollView.minimumZoomScale = minScale
|
||||||
scrollView.zoomScale = minScale
|
scrollView.zoomScale = minScale
|
||||||
|
|
Loading…
Reference in New Issue