Convenient class to handle the new iPhone 5 taller screen
#import "Device.h" | |
@implementation Device | |
+(BOOL)isScreen4Inch { | |
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { | |
CGRect screenBounds = [[UIScreen mainScreen] bounds]; | |
if (screenBounds.size.height == 568) | |
return YES; | |
} | |
return NO; | |
} | |
@end | |
@implementation UIImage (iPhone568) | |
+(UIImage*)imageNamedFor568h:(NSString*)imageName { | |
if ([Device isScreen4Inch]) { | |
NSString *imageNameFor568h = [NSString stringWithFormat:@"%@-568h.%@", [imageName stringByDeletingPathExtension], [imageName pathExtension]]; | |
return [UIImage imageNamed:imageNameFor568h]; | |
} | |
return [UIImage imageNamed:imageName]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment