Fix large image controls being positioned incorrectly on notched-devices
when opening via a context menu preview. The constraints for the top controls were being set only once, but when showing a large image in the contxt menu preview window, the top inset safe area is 0 and didn't become 44 (the value for notched devices) until the preview was expanded. Fixes #86
This commit is contained in:
parent
20c602f911
commit
8c7bebcce8
|
@ -37,8 +37,6 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate {
|
||||||
@IBOutlet weak var bottomControlsView: UIView!
|
@IBOutlet weak var bottomControlsView: UIView!
|
||||||
@IBOutlet weak var descriptionLabel: UILabel!
|
@IBOutlet weak var descriptionLabel: UILabel!
|
||||||
|
|
||||||
var initializedTopControlsConstrains = false
|
|
||||||
|
|
||||||
var image: UIImage?
|
var image: UIImage?
|
||||||
var gifData: Data?
|
var gifData: Data?
|
||||||
var imageDescription: String?
|
var imageDescription: String?
|
||||||
|
@ -120,16 +118,13 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate {
|
||||||
|
|
||||||
centerImage()
|
centerImage()
|
||||||
|
|
||||||
if !initializedTopControlsConstrains {
|
if view.safeAreaInsets.top == 44 {
|
||||||
initializedTopControlsConstrains = true
|
// running on iPhone X style notched device
|
||||||
if view.safeAreaInsets.top == 44 {
|
let notchWidth: CGFloat = 209
|
||||||
// running on iPhone X style notched device
|
let earWidth = (view.bounds.width - notchWidth) / 2
|
||||||
let notchWidth: CGFloat = 209
|
let offset = (earWidth - shareButton.bounds.width) / 2
|
||||||
let earWidth = (view.bounds.width - notchWidth) / 2
|
shareButtonLeadingConstraint.constant = offset
|
||||||
let offset = (earWidth - shareButton.bounds.width) / 2
|
closeButtonTrailingConstraint.constant = offset
|
||||||
shareButtonLeadingConstraint.constant = offset
|
|
||||||
closeButtonTrailingConstraint.constant = offset
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue