Skip to content

Commit 670ff01

Browse files
committed
Fix warnings
1 parent 51e7ecc commit 670ff01

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Sources/Impl/PinSafeArea.swift

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,7 @@ internal class PinSafeArea {
5858
// noop on iOS 11, `UIView.safeAreaInsetsDidChange` is natively supported
5959
} else {
6060
guard currentSafeAreaInsetsDidChangeMode == nil else { return }
61-
if #available(iOS 9.0, tvOS 9.0, *) {
62-
PinSafeArea.safeAreaInsetsDidChangeMode = .always
63-
} else {
64-
// Due to an issue with the keyboard on iOS 8, we don't activate
65-
// the support of `UIView.safeAreaInsetsDidChange` on iOS 8. The developper can still
66-
// activate it using `Pin.enableSafeArea(true)`
67-
PinSafeArea.safeAreaInsetsDidChangeMode = .disable
68-
}
61+
PinSafeArea.safeAreaInsetsDidChangeMode = .always
6962
}
7063
}
7164

@@ -163,8 +156,15 @@ struct PinLayoutSwizzling {
163156
if #available(iOS 11.0, tvOS 11.0, *) { assertionFailure() }
164157

165158
if let view = viewController.view {
166-
let safeAreaInsets = UIEdgeInsets(top: viewController.topLayoutGuide.length, left: 0,
159+
let safeAreaInsets: UIEdgeInsets
160+
161+
if #available(iOS 11.0, *) {
162+
safeAreaInsets = UIEdgeInsets(top: viewController.view.safeAreaInsets.top, left: 0,
163+
bottom: viewController.view.safeAreaInsets.bottom, right: 0)
164+
} else {
165+
safeAreaInsets = UIEdgeInsets(top: viewController.topLayoutGuide.length, left: 0,
167166
bottom: viewController.bottomLayoutGuide.length, right: 0)
167+
}
168168

169169
// Set children safeArea up to 3 level, to limit the performance issue of computing this compatibilitySafeAreaInsets
170170
PinSafeArea.setViewSafeAreaInsets(view: view, insets: safeAreaInsets, recursiveLevel: 3)
@@ -201,8 +201,13 @@ extension UIView {
201201
// UIViewController.viewWillLayoutSubviews hasn't been swizzled, we can return an insets
202202
// only if the view is a UIViewController's view.
203203
if let viewController = self.next as? UIViewController {
204-
return UIEdgeInsets(top: viewController.topLayoutGuide.length, left: 0,
205-
bottom: viewController.bottomLayoutGuide.length, right: 0)
204+
if #available(iOS 11.0, *) {
205+
return UIEdgeInsets(top: viewController.view.safeAreaInsets.top, left: 0,
206+
bottom: viewController.view.safeAreaInsets.bottom, right: 0)
207+
} else {
208+
return UIEdgeInsets(top: viewController.topLayoutGuide.length, left: 0,
209+
bottom: viewController.bottomLayoutGuide.length, right: 0)
210+
}
206211
} else {
207212
return .zero
208213
}

0 commit comments

Comments
 (0)