#define iPhoneXSeries (([[UIApplication sharedApplication] statusBarFrame].size.height == 44.0f) ? (YES):(NO))
有隐藏的麻烦吗?
或有更好的方法吗?
我需要知道,因为iPhonex系列栏的高度是不可变的,但其他iPhone的状态栏的高度可能会改变
属性和UIView
safeAreaInsets
safeAreaInsetsDidChange()
方法,当安全区域更改时,系统将调用该属性(例如,当状态栏高度更改时)。然后,您可以调整内容以适合新的安全插图。以这种方式构建您的应用程序意味着您不必担心应用程序破坏您不期望的功能集的新设备模型,并且您不必担心将来的iOS更新会破坏您的假设。
trone this:
let size = UIScreen.mainScreen().bounds.size
print("Your device size: \(size)");
if size.height == 814 {
print("This is an iPhone X")
}