Skip to content

Instantly share code, notes, and snippets.

@eytanschulman
Created September 13, 2014 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eytanschulman/8668944bbe799ff90b4f to your computer and use it in GitHub Desktop.
Save eytanschulman/8668944bbe799ff90b4f to your computer and use it in GitHub Desktop.
Check for iPhone 3.5",4",4.7" or 5.5"
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
NSLog(@"Device is iPhone 4");
}
if(result.height == 568)
{
NSLog(@"Device is iPhone 5s");
}
if (result.height == 667) {
NSLog(@"Device is iPhone 6");
}
if (result.height == 736) {
NSLog(@"Device is iPhone 6 Plus");
}
}
@LK
Copy link

LK commented Sep 13, 2014

If you intend for this to be used as a snippet, I would replace the NSLogs with <#iPhone 4#>, <#iPhone 5s#>, etc, it'll show the Xcode placeholder instead of logging code that most people will delete anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment