Created
March 20, 2017 19:51
-
-
Save JasonCanCode/aa9d0859f62297ea2e2ce1cdc0036a1e to your computer and use it in GitHub Desktop.
Quickly determine the screen type of the device
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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