Created
April 24, 2020 21:38
-
-
Save Tprezioso/0987528a6ea6bd9e218631581af462fd to your computer and use it in GitHub Desktop.
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 ScreenSize { | |
static let width = UIScreen.main.bounds.size.width | |
static let height = UIScreen.main.bounds.size.height | |
static let maxLength = max(ScreenSize.width, ScreenSize.height) | |
static let minLength = min(ScreenSize.width, ScreenSize.height) | |
} | |
enum DeviceType { | |
static let idiom = UIDevice.current.userInterfaceIdiom | |
static let nativeScale = UIScreen.main.nativeScale | |
static let scale = UIScreen.main.scale | |
static let isiPhoneSE = idiom == .phone && ScreenSize.maxLength == 568.0 | |
static let isiPhone8Standard = idiom == .phone && ScreenSize.maxLength == 667.0 && nativeScale == scale | |
static let isiPhone8Zoomed = idiom == .phone && ScreenSize.maxLength == 667.0 && nativeScale > scale | |
static let isiPhone8PlusStandard = idiom == .phone && ScreenSize.maxLength == 736.0 | |
static let isiPhone8PlusZoomed = idiom == .phone && ScreenSize.maxLength == 736.0 && nativeScale < scale | |
static let isiPhoneX = idiom == .phone && ScreenSize.maxLength == 812.0 | |
static let isiPhoneXsMaxAndXr = idiom == .phone && ScreenSize.maxLength == 896.0 | |
static let isiPad = idiom == .phone && ScreenSize.maxLength == 1024.0 | |
static func isiPhoneXAspectRation() -> Bool { | |
return isiPhoneX || isiPhoneXsMaxAndXr | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment