Skip to content

Commit dc6dd5b

Browse files
author
Thomas Taschauer
committed
fix layout for notches
1 parent e111b0f commit dc6dd5b

2 files changed

Lines changed: 38 additions & 59 deletions

File tree

OpenDocumentReader/DocumentViewController.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ class DocumentViewController: UIViewController, DocumentDelegate {
3939
@IBOutlet weak var webview: WKWebView!
4040
@IBOutlet weak var progressBar: UIProgressView!
4141

42-
@IBOutlet weak var toolbar: UIToolbar!
43-
@IBOutlet weak var toolbarDefaultHeight: NSLayoutConstraint!
44-
@IBOutlet weak var toolbarFullscreenHeight: NSLayoutConstraint!
4542
@IBOutlet weak var menuButton: UIBarButtonItem!
4643

4744
private var isFullscreen = false
@@ -121,17 +118,10 @@ class DocumentViewController: UIViewController, DocumentDelegate {
121118
}
122119
Analytics.logEvent(event, parameters: nil)
123120

124-
let topInset = isFullscreen ? 0 : 8
125-
menuButton.imageInsets = UIEdgeInsets(top: CGFloat(topInset), left: 0, bottom: 0, right: 0)
126-
127121
setNeedsStatusBarAppearanceUpdate()
128122
}
129123

130124
override var prefersStatusBarHidden: Bool {
131-
let constraint = (isFullscreen ? toolbarFullscreenHeight : toolbarDefaultHeight)!
132-
toolbar.removeConstraints([toolbarFullscreenHeight, toolbarDefaultHeight])
133-
toolbar.addConstraint(constraint)
134-
135125
return isFullscreen
136126
}
137127

OpenDocumentReader/Main.storyboard

Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3-
<device id="retina4_0" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15400" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15404"/>
7+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
98
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
109
</dependencies>
1110
<scenes>
1211
<!--Document Browser View Controller-->
1312
<scene sceneID="tne-QT-ifu">
1413
<objects>
1514
<viewController id="BYZ-38-t0r" customClass="DocumentBrowserViewController" customModule="OpenDocumentReader" customModuleProvider="target" sceneMemberID="viewController">
16-
<layoutGuides>
17-
<viewControllerLayoutGuide type="top" id="JCg-Yp-JI7"/>
18-
<viewControllerLayoutGuide type="bottom" id="hAi-w7-sTw"/>
19-
</layoutGuides>
2015
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
21-
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
16+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
2217
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2318
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
19+
<viewLayoutGuide key="safeArea" id="Ps8-jH-9pK"/>
2420
</view>
2521
</viewController>
2622
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
@@ -31,23 +27,22 @@
3127
<scene sceneID="dkP-xk-x6W">
3228
<objects>
3329
<viewController storyboardIdentifier="TextDocumentViewController" id="M2k-L8-Olo" customClass="DocumentViewController" customModule="OpenDocumentReader" customModuleProvider="target" sceneMemberID="viewController">
34-
<layoutGuides>
35-
<viewControllerLayoutGuide type="top" id="AMW-PC-cPn"/>
36-
<viewControllerLayoutGuide type="bottom" id="LvO-fG-AYW"/>
37-
</layoutGuides>
3830
<view key="view" contentMode="scaleToFill" id="SIE-Uh-Zny">
39-
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
31+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
4032
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
4133
<subviews>
34+
<view hidden="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sKS-nk-f6M">
35+
<rect key="frame" x="0.0" y="0.0" width="0.0" height="44"/>
36+
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
37+
<accessibility key="accessibilityConfiguration">
38+
<accessibilityTraits key="traits" notEnabled="YES"/>
39+
</accessibility>
40+
</view>
4241
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="9mi-yf-jXf">
43-
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
42+
<rect key="frame" x="0.0" y="0.0" width="414" height="88"/>
4443
<subviews>
4544
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="N1x-QM-Qks">
46-
<rect key="frame" x="0.0" y="0.0" width="320" height="64"/>
47-
<constraints>
48-
<constraint firstAttribute="height" constant="64" id="7HG-pa-6VL"/>
49-
<constraint firstAttribute="height" priority="999" constant="44" id="wgs-N3-sP6"/>
50-
</constraints>
45+
<rect key="frame" x="0.0" y="0.0" width="414" height="88"/>
5146
<items>
5247
<barButtonItem title="Back to documents" id="yhO-7V-lbn">
5348
<connections>
@@ -62,60 +57,54 @@
6257
</connections>
6358
</barButtonItem>
6459
</items>
65-
<variation key="default">
66-
<mask key="constraints">
67-
<exclude reference="7HG-pa-6VL"/>
68-
<exclude reference="wgs-N3-sP6"/>
69-
</mask>
70-
</variation>
71-
<variation key="heightClass=regular">
72-
<mask key="constraints">
73-
<include reference="7HG-pa-6VL"/>
74-
</mask>
75-
</variation>
7660
</toolbar>
7761
<view hidden="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sIx-zo-9kG" customClass="ScrollableSegmentedControl" customModule="ScrollableSegmentedControl">
78-
<rect key="frame" x="0.0" y="64" width="320" height="30"/>
62+
<rect key="frame" x="0.0" y="0.0" width="414" height="30"/>
7963
<color key="backgroundColor" red="0.97636479139328003" green="0.97653168439865112" blue="0.97635418176651001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
8064
<constraints>
8165
<constraint firstAttribute="height" constant="30" id="P24-FV-92V"/>
8266
</constraints>
8367
</view>
8468
<progressView hidden="YES" opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="ePk-bQ-fV8">
85-
<rect key="frame" x="0.0" y="64" width="320" height="0.0"/>
69+
<rect key="frame" x="0.0" y="0.0" width="414" height="0.0"/>
8670
</progressView>
87-
<wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VF5-Do-xh9">
88-
<rect key="frame" x="0.0" y="64" width="320" height="504"/>
89-
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
90-
<wkWebViewConfiguration key="configuration">
91-
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
92-
<wkPreferences key="preferences"/>
93-
</wkWebViewConfiguration>
94-
</wkWebView>
9571
</subviews>
9672
</stackView>
73+
<wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VF5-Do-xh9">
74+
<rect key="frame" x="0.0" y="88" width="414" height="808"/>
75+
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
76+
<wkWebViewConfiguration key="configuration">
77+
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
78+
<wkPreferences key="preferences"/>
79+
</wkWebViewConfiguration>
80+
</wkWebView>
9781
</subviews>
9882
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
9983
<constraints>
100-
<constraint firstItem="9mi-yf-jXf" firstAttribute="leading" secondItem="SIE-Uh-Zny" secondAttribute="leadingMargin" constant="-16" id="5Hh-GZ-aPw"/>
101-
<constraint firstItem="9mi-yf-jXf" firstAttribute="bottom" secondItem="SIE-Uh-Zny" secondAttribute="bottom" id="WfC-A6-p6P"/>
84+
<constraint firstItem="9mi-yf-jXf" firstAttribute="leading" secondItem="HAk-oU-gAF" secondAttribute="leading" id="5Hh-GZ-aPw"/>
85+
<constraint firstItem="VF5-Do-xh9" firstAttribute="top" secondItem="9mi-yf-jXf" secondAttribute="bottom" id="8K3-ke-I1G"/>
86+
<constraint firstItem="sKS-nk-f6M" firstAttribute="top" secondItem="SIE-Uh-Zny" secondAttribute="top" id="HjQ-CN-3cF"/>
87+
<constraint firstItem="VF5-Do-xh9" firstAttribute="leading" secondItem="HAk-oU-gAF" secondAttribute="leading" id="OvL-SW-INd"/>
88+
<constraint firstItem="VF5-Do-xh9" firstAttribute="trailing" secondItem="HAk-oU-gAF" secondAttribute="trailing" id="Qyj-ei-4NG"/>
89+
<constraint firstItem="N1x-QM-Qks" firstAttribute="top" secondItem="9mi-yf-jXf" secondAttribute="top" id="Yiq-pe-hl5"/>
90+
<constraint firstItem="N1x-QM-Qks" firstAttribute="bottom" secondItem="sKS-nk-f6M" secondAttribute="bottom" constant="44" id="fDF-Mx-Nxy"/>
91+
<constraint firstItem="VF5-Do-xh9" firstAttribute="bottom" secondItem="SIE-Uh-Zny" secondAttribute="bottom" id="ftB-8D-F6n"/>
92+
<constraint firstItem="sKS-nk-f6M" firstAttribute="bottom" secondItem="HAk-oU-gAF" secondAttribute="top" id="gWh-EO-FK9"/>
10293
<constraint firstItem="9mi-yf-jXf" firstAttribute="top" secondItem="SIE-Uh-Zny" secondAttribute="top" id="rED-wA-6gv"/>
103-
<constraint firstAttribute="trailingMargin" secondItem="9mi-yf-jXf" secondAttribute="trailing" constant="-16" id="tPc-vX-Egd"/>
94+
<constraint firstItem="9mi-yf-jXf" firstAttribute="trailing" secondItem="HAk-oU-gAF" secondAttribute="trailing" id="tPc-vX-Egd"/>
10495
</constraints>
96+
<viewLayoutGuide key="safeArea" id="HAk-oU-gAF"/>
10597
</view>
10698
<connections>
10799
<outlet property="menuButton" destination="Vsd-IL-ujz" id="GoN-tp-egn"/>
108100
<outlet property="progressBar" destination="ePk-bQ-fV8" id="nz6-qw-ouf"/>
109101
<outlet property="segmentedControl" destination="sIx-zo-9kG" id="pCn-x0-Z01"/>
110-
<outlet property="toolbar" destination="N1x-QM-Qks" id="PLi-vF-UnF"/>
111-
<outlet property="toolbarDefaultHeight" destination="7HG-pa-6VL" id="JBe-4t-6dM"/>
112-
<outlet property="toolbarFullscreenHeight" destination="wgs-N3-sP6" id="r1r-Cs-BMt"/>
113102
<outlet property="webview" destination="VF5-Do-xh9" id="25W-hb-tHy"/>
114103
</connections>
115104
</viewController>
116105
<placeholder placeholderIdentifier="IBFirstResponder" id="Rl9-ES-qQn" userLabel="First Responder" sceneMemberID="firstResponder"/>
117106
</objects>
118-
<point key="canvasLocation" x="1029.5999999999999" y="653.52323838080963"/>
107+
<point key="canvasLocation" x="1028.985507246377" y="652.90178571428567"/>
119108
</scene>
120109
</scenes>
121110
</document>

0 commit comments

Comments
 (0)