Last active
October 27, 2015 15:20
-
-
Save chrisjp/f24903dfe4f9d1c7f0c9 to your computer and use it in GitHub Desktop.
Useful iOS screen size macros
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
// Devices | |
#define ScreenHeight MAX([[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height) | |
#define ScreenWidth MIN([[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height) | |
#define Screen35in (ScreenHeight==480) | |
#define Screen40in (ScreenHeight==568) | |
#define Screen47in (ScreenHeight==667) | |
#define Screen55in (ScreenHeight==736) | |
#define iPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | |
#define iPadPro ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) && (ScreenHeight==1366)) | |
/* USAGE */ | |
if (Screen55in) { | |
// Code specifically for iPhone 6+ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credit to @swaterfall for the tip about using screen height as a more reliable way to detect devices.