Created
September 26, 2017 11:40
-
-
Save mahmudahsan/e98b6561ded173b66fb62eaf0b8903e4 to your computer and use it in GitHub Desktop.
iPhone X and other iOS device detection by Swift and Objective-C
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
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | |
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) | |
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0) | |
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width) | |
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height) | |
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT)) | |
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT)) | |
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0) | |
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0) | |
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0) | |
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0) | |
#define IS_IPHONE_X (IS_IPHONE && SCREEN_MAX_LENGTH == 812.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment