【发布时间】:2018-01-18 06:28:06
【问题描述】:
当打印 iPhone 6+ 模拟器的屏幕高度时,我得到了 2208,正如预期的那样。但是,当我在实际的 iPhone 6+ 上进行测试时,我得到了 1920。非常困惑哪个是正确的。这是我正在使用的代码:
func test() {
if UIDevice().userInterfaceIdiom == .phone {
switch UIScreen.main.nativeBounds.height {
case 1136:
print("iPhone 5 or 5S or 5C")
case 1334:
print("iPhone 6/6S/7/8")
case 2208:
print("iPhone 6+/6S+/7+/8+")
case 2436:
print("iPhone X")
default:
print("unknown")
}
}
}
【问题讨论】: