Created
April 4, 2023 18:31
-
-
Save MickhailP/c041528f702ac9c2124cdab8335ff135 to your computer and use it in GitHub Desktop.
ScreenSizes
This file contains 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 DeviceTypes { | |
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 == .pad && ScreenSize.maxLength >= 1024.0 | |
static func isiPhoneXAspectRatio() -> Bool { | |
return isiPhoneX || isiPhoneXsMaxAndXr | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment