Skip to content

Instantly share code, notes, and snippets.

@lizixroy
Created May 14, 2015 04:29
Show Gist options
  • Save lizixroy/e5dd4f9702274449e10c to your computer and use it in GitHub Desktop.
Save lizixroy/e5dd4f9702274449e10c to your computer and use it in GitHub Desktop.
Macros for checking the iPhone model based on screen sizes.
// macros that can be used to quickly check the model of current iPhone in your Objective-C code.
#define IS_IPHONE_6_PLUS ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )736 ) < DBL_EPSILON )
#define IS_IPHONE_6 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )667 ) < DBL_EPSILON )
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IS_IPHONE_4 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )480 ) < DBL_EPSILON )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment