Fix tall gallery content being inset on the bottom edge
This commit is contained in:
parent
da4787946d
commit
4fb7cacf31
@ -228,6 +228,10 @@ class GalleryItemViewController: UIViewController {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillUpdate), name: UIResponder.keyboardWillShowNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillUpdate), name: UIResponder.keyboardWillHideNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillUpdate), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
|
||||
|
||||
if #available(iOS 17.0, *) {
|
||||
view.keyboardLayoutGuide.usesBottomSafeArea = false
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func keyboardWillUpdate() {
|
||||
@ -354,7 +358,17 @@ class GalleryItemViewController: UIViewController {
|
||||
return
|
||||
}
|
||||
|
||||
let heightScale = (view.bounds.height - view.keyboardLayoutGuide.layoutFrame.height) / content.contentSize.height
|
||||
// Post-iOS 17, we can ask the keyboard layout guide to ignore the bottom safe area.
|
||||
// Pre, we have to do that ourselves.
|
||||
let keyboardHeight: CGFloat
|
||||
if #available(iOS 17.0, *) {
|
||||
keyboardHeight = view.keyboardLayoutGuide.layoutFrame.height
|
||||
} else {
|
||||
let bottomSafeArea = view.bounds.height - view.safeAreaLayoutGuide.layoutFrame.maxY
|
||||
let rawKeyboardHeight = view.keyboardLayoutGuide.layoutFrame.height
|
||||
keyboardHeight = abs(rawKeyboardHeight - bottomSafeArea) < 1 ? 0 : rawKeyboardHeight
|
||||
}
|
||||
let heightScale = (view.bounds.height - keyboardHeight) / content.contentSize.height
|
||||
let widthScale = view.bounds.width / content.contentSize.width
|
||||
let minScale = min(widthScale, heightScale)
|
||||
let maxScale = minScale >= 1 ? minScale + 2 : 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user