Wenfengcheng / xamarin-notes

xamarin journal
MIT License
3 stars 0 forks source link

Check if device is iPhone X #5

Open Wenfengcheng opened 5 years ago

Wenfengcheng commented 5 years ago
    /// Check if device is iPhone X,
    /// reference: http://www.glimsoft.com/09/14/5-tips-tricks-for-updating-your-app-for-iphone-x/
    static var isIphoneX: Bool {
        if #available(iOS 11, *) {
            guard let insets = UIApplication.shared.delegate?.window??.safeAreaInsets else { return false }
            return insets.top > CGFloat(0.0)
        } else {
            return false
        }
    }