-
-
Save kerasking/5195023 to your computer and use it in GitHub Desktop.
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
| // Consider "applicationFrame" also with status bar. | |
| CGRect screenBounds = [[UIScreen mainScreen] bounds]; | |
| if (screenBounds.size.height == 568) { | |
| // code for 4-inch screen | |
| } else { | |
| // code for 3.5-inch screen | |
| } | |
| //or | |
| if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) | |
| { | |
| CGSize result = [[UIScreen mainScreen] bounds].size; | |
| if(result.height == 480) | |
| { | |
| // iPhone Classic | |
| } | |
| if(result.height == 568) | |
| { | |
| // iPhone 5 | |
| } | |
| } | |
| // or function about iPhone 5 | |
| BOOL IS_IPHONE5_RETINA(void) { | |
| BOOL isiPhone5Retina = NO; | |
| if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { | |
| if ([UIScreen mainScreen].scale == 2.0f) { | |
| CGSize result = [[UIScreen mainScreen] bounds].size; | |
| CGFloat scale = [UIScreen mainScreen].scale; | |
| result = CGSizeMake(result.width * scale, result.height * scale); | |
| if(result.height == 960){ | |
| //NSLog(@"iPhone 4, 4s Retina Resolution"); | |
| } | |
| if(result.height == 1136){ | |
| //NSLog(@"iPhone 5 Resolution"); | |
| isiPhone5Retina = YES; | |
| } | |
| } else { | |
| //NSLog(@"iPhone Standard Resolution"); | |
| } | |
| } | |
| return isiPhone5Retina; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment