Fix large image view top controls on iPhone Xs Max & Xr
This commit is contained in:
parent
6f424666d8
commit
76972237ba
|
@ -25,9 +25,9 @@ class MastodonController {
|
||||||
|
|
||||||
client = Client(baseURL: url)
|
client = Client(baseURL: url)
|
||||||
|
|
||||||
if let accessToken = LocalData.shared.accessToken {
|
client.clientID = LocalData.shared.clientID
|
||||||
client.accessToken = accessToken
|
client.clientSecret = LocalData.shared.clientSecret
|
||||||
}
|
client.accessToken = LocalData.shared.accessToken
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerApp(completion: @escaping () -> Void) {
|
func registerApp(completion: @escaping () -> Void) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="8pH-Ao-p7G">
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="8pH-Ao-p7G">
|
||||||
<device id="retina4_7" orientation="portrait">
|
<device id="retina4_7" orientation="portrait">
|
||||||
<adaptation id="fullscreen"/>
|
<adaptation id="fullscreen"/>
|
||||||
</device>
|
</device>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.9"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
|
||||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -47,6 +47,8 @@ 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 imageDescription: String?
|
var imageDescription: String?
|
||||||
|
|
||||||
|
@ -82,23 +84,31 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate {
|
||||||
bottomControlsView.isHidden = true
|
bottomControlsView.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// if running on iPhone X
|
|
||||||
if UIScreen.main.nativeBounds.height == 2436 {
|
|
||||||
topControlsHeightConstraint.constant = 35
|
|
||||||
downloadButtonLeadingConstraint.constant = 35
|
|
||||||
closeButtonTrailingConstraint.constant = 35
|
|
||||||
}
|
|
||||||
|
|
||||||
dismissInteractionController = LargeImageInteractionController(viewController: self)
|
dismissInteractionController = LargeImageInteractionController(viewController: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override func viewDidLayoutSubviews() {
|
override func viewDidLayoutSubviews() {
|
||||||
|
super.viewDidLayoutSubviews()
|
||||||
|
|
||||||
let widthScale = view.bounds.size.width / imageView.bounds.width
|
let widthScale = view.bounds.size.width / imageView.bounds.width
|
||||||
let heightScale = view.bounds.size.height / imageView.bounds.height
|
let heightScale = view.bounds.size.height / imageView.bounds.height
|
||||||
let minScale = min(widthScale, heightScale)
|
let minScale = min(widthScale, heightScale)
|
||||||
scrollView.minimumZoomScale = minScale
|
scrollView.minimumZoomScale = minScale
|
||||||
scrollView.zoomScale = minScale
|
scrollView.zoomScale = minScale
|
||||||
scrollView.maximumZoomScale = minScale >= 1 ? minScale + 2 : 2
|
scrollView.maximumZoomScale = minScale >= 1 ? minScale + 2 : 2
|
||||||
|
|
||||||
|
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 - downloadButton.bounds.width) / 2
|
||||||
|
downloadButtonLeadingConstraint.constant = offset
|
||||||
|
closeButtonTrailingConstraint.constant = offset
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
|
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
|
||||||
|
|
Loading…
Reference in New Issue