How To Detect if the device is iPhone X?

This tutorial to use detection of Device. Accounting to device developer can put the condition for devices.



Detection device Swift 4: 
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 1920, 2208:
            print("iPhone 6+/6S+/7+/8+")
        case 2436:
            print("iPhone X")
        default:
            print("unknown")
        }
    }

Thanks.
How To Detect if the device is iPhone X? How To Detect if the device is iPhone X? Reviewed by KIRIT MODI on 22:32:00 Rating: 5

No comments:

Powered by Blogger.