How to check if the device is iPhoneX or not in iOS swift

Problem:

I want to detect the phone is iPhone X or other models.Because based on that i want to change my app constraints.


Solution:

The below condition will be works if the device is iphone X.In else we can put the other phone model codes will execute.

if UIDevice().userInterfaceIdiom == .phone && UIScreen.main.nativeBounds.height == 2436{

} else {
//other device codes will be here
}

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift