rxg9527
12/26/2017 - 2:14 AM

判断 iPhone 机型

判断 iPhone 机型

extension UIDevice {
    static func isX() -> Bool {
        if UIDevice().userInterfaceIdiom == .phone {
            switch UIScreen.main.nativeBounds.height {
            case 2436:
                return true
            default:
                return false
                //            case 480:
                //                print("iPhone Classic")
                //            case 960:
                //                print("iPhone 4 or 4S")
                //            case 1136:
                //                print("iPhone 5 or 5S or 5C")
                //            case 1334:
                //                print("iPhone 6 or 6S")
                //            case 2208:
                //                print("iPhone 6+ or 6S+")
                //            case 2436:
                //                print("iPhone X")
            }
        }
        return false
    }
}