Created
January 3, 2018 18:05
-
-
Save aainaj/138fc440186ee5b68e1c5fb20439565b to your computer and use it in GitHub Desktop.
Swift equivalent code of #define
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
struct Device { | |
static let IS_IPAD = UIDevice.current.userInterfaceIdiom == .pad | |
static let IS_IPHONE = UIDevice.current.userInterfaceIdiom == .phone | |
static let IS_RETINA = UIScreen.main.scale >= 2.0 | |
static let SCREEN_WIDTH = Int(UIScreen.main.bounds.size.width) | |
static let SCREEN_HEIGHT = Int(UIScreen.main.bounds.size.height) | |
static let SCREEN_MAX_LENGTH = Int( max(SCREEN_WIDTH, SCREEN_HEIGHT) ) | |
static let SCREEN_MIN_LENGTH = Int( min(SCREEN_WIDTH, SCREEN_HEIGHT) ) | |
static let IS_IPHONE_4_OR_LESS = IS_IPHONE && SCREEN_MAX_LENGTH < 568 | |
static let IS_IPHONE_5 = IS_IPHONE && SCREEN_MAX_LENGTH == 568 | |
static let IS_IPHONE_6 = IS_IPHONE && SCREEN_MAX_LENGTH == 667 | |
static let IS_IPHONE_6P = IS_IPHONE && SCREEN_MAX_LENGTH == 736 | |
static let IS_IPHONE_X = IS_IPHONE && SCREEN_MAX_LENGTH == 812 | |
} | |
if (Device.IS_IPHONE_X){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment