Skip to content

iOS Get Screen sizes for iPhone/iPad

Platform Language License

About

A custom class to identify screensize of various devices.

Overview

  • Easy customization
  • Swift 5.0 above
  • Xcode 11 above
  • Orientation support
  • Manual drag & drop the class
  • iPhone/iPad support

ScreenSizes

ScreenSizes

Workflow

  • Import UIScreen+ScreenSize.swift into you project
  • If you need to design specifically for iPhoneX series use the below code.
if UIScreen.screenSizeType().isIPhoneX {
    print("iPhoneX models...")
}

  • For other uses like if you need to redesign for iPhoneSE & similar smaller devices, you can go with switch cases.
switch UIScreen.screenSizeType() {
    case .inch4(.portrait),.inch4(.landscape):
        print("iPhoneSE")
    case .inch4_7:
        print("iPhone8")
    default:
        break
}

print(UIScreen.screenSizeType())

Output

iPhoneX models...
inch6_1(Macros.ScreenOrientation.portrait)

Reference: iPhoneResolutions

Download the file here

UIScreen+ScreenSize.swift

Github

License

UIScreen+ScreenSize is distributed under the MIT license .


Let's grow together 🌱

Cheers 🍻