In Objective-C we can get device width and height by using following code :
CGRect sizeRect = [UIScreen mainScreen].applicationFrame
float width = sizeRect.
If you want to use it in your code. Here you go.
func iPhoneScreenSizes() {
let bounds = UIScreen.main.bounds
let height = bounds.size.height
switch height {
case 480.0:
print("iPhone 3,4")
case 568.0:
print("iPhone 5")
case 667.0:
print("iPhone 6")
case 736.0:
print("iPhone 6+")
case 812.0:
print("iPhone X")
print("iPhone XS")
break
case 896.0:
print("iPhone XR")
print("iPhone XS Max")
break
default:
print("not an iPhone")
}
}