Skip to content

Instantly share code, notes, and snippets.

@JasonCanCode
Created March 20, 2017 19:51
Show Gist options
  • Save JasonCanCode/aa9d0859f62297ea2e2ce1cdc0036a1e to your computer and use it in GitHub Desktop.
Save JasonCanCode/aa9d0859f62297ea2e2ce1cdc0036a1e to your computer and use it in GitHub Desktop.
Quickly determine the screen type of the device
enum DeviceScreenType {
case fourOrLess, five, six, sixPlus
}
struct DeviceHelper {
static var screenType: DeviceScreenType {
let maxScreenLength = max(UIScreen.main.bounds.size.width, UIScreen.main.bounds.size.height)
if maxScreenLength < 568.0 {
return .fourOrLess
} else if maxScreenLength < 667.0 {
return .five
} else if maxScreenLength < 736.0 {
return .six
} else {
return .sixPlus
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment