Skip to content

Instantly share code, notes, and snippets.

@stleamist
Last active November 27, 2019 05:44
Show Gist options
  • Save stleamist/fa1f9e9bae377669c84e40051608736a to your computer and use it in GitHub Desktop.
Save stleamist/fa1f9e9bae377669c84e40051608736a to your computer and use it in GitHub Desktop.
import UIKit
extension UIDevice {
var hasHomeIndicatorArea: Bool? {
// AppDelegate에서 window의 makeKeyAndVisible()이 호출되기 전에는 keyWindow 프로퍼티가 nil 값을 반환하므로,
// 그 전에는 AppDelegate window 프로퍼티를 가져오도록 한다.
guard let window: UIWindow = UIApplication.shared.keyWindow ?? UIApplication.shared.delegate?.window ?? nil else {
return nil
}
let bottomSafeAreaInsets = window.safeAreaInsets.bottom
return bottomSafeAreaInsets > 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment