forked from shadowfacts/Tusker
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 descriptionLabel: UILabel!
|
||||
|
||||
var initializedTopControlsConstrains = false
|
||||
|
||||
var image: UIImage?
|
||||
var gifData: Data?
|
||||
var imageDescription: String?
|
||||
|
@ -120,16 +118,13 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate {
|
|||
|
||||
centerImage()
|
||||
|
||||
if !initializedTopControlsConstrains {
|
||||
initializedTopControlsConstrains = true
|
||||
if view.safeAreaInsets.top == 44 {
|
||||
// running on iPhone X style notched device
|
||||
let notchWidth: CGFloat = 209
|
||||
let earWidth = (view.bounds.width - notchWidth) / 2
|
||||
let offset = (earWidth - shareButton.bounds.width) / 2
|
||||
shareButtonLeadingConstraint.constant = offset
|
||||
closeButtonTrailingConstraint.constant = offset
|
||||
}
|
||||
if view.safeAreaInsets.top == 44 {
|
||||
// running on iPhone X style notched device
|
||||
let notchWidth: CGFloat = 209
|
||||
let earWidth = (view.bounds.width - notchWidth) / 2
|
||||
let offset = (earWidth - shareButton.bounds.width) / 2
|
||||
shareButtonLeadingConstraint.constant = offset
|
||||
closeButtonTrailingConstraint.constant = offset
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue