Use keyPath to read UIApplication.shared. (#81)

This commit is contained in:
Abdullah Selek 2020-02-12 19:02:33 +00:00 committed by GitHub
parent 7f07cdff27
commit 1e7c0534fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -27,7 +27,10 @@ extension PanModalPresentable where Self: UIViewController {
Gives us the safe area inset from the top.
*/
var topLayoutOffset: CGFloat {
return UIApplication.shared.keyWindow?.rootViewController?.topLayoutGuide.length ?? 0
guard let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication else {
return 0
}
return application.keyWindow?.rootViewController?.topLayoutGuide.length ?? 0
}
/**
@ -35,7 +38,10 @@ extension PanModalPresentable where Self: UIViewController {
Gives us the safe area inset from the bottom.
*/
var bottomLayoutOffset: CGFloat {
return UIApplication.shared.keyWindow?.rootViewController?.bottomLayoutGuide.length ?? 0
guard let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication else {
return 0
}
return application.keyWindow?.rootViewController?.bottomLayoutGuide.length ?? 0
}
/**