Skip to content

Instantly share code, notes, and snippets.

@GregoryMaks
Created January 28, 2015 14:55
Show Gist options
  • Save GregoryMaks/816780312ec3694b3d52 to your computer and use it in GitHub Desktop.
Save GregoryMaks/816780312ec3694b3d52 to your computer and use it in GitHub Desktop.
LaunchImages
+ (UIImage *)launchImageWithPrefix:(NSString *)prefix interfaceOrientation:(UIInterfaceOrientation)orientation
{
NSString *imageName = nil;
// TODO.GregoryM: fillup rest of image names and check in different cases
CGFloat mainScreenHeight = CGRectGetHeight([UIScreen mainScreen].bounds);
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
if (mainScreenHeight == 568) {
imageName = UIInterfaceOrientationIsPortrait(orientation) ? @"-700-568h@2x.png" : nil;
}
else if (mainScreenHeight == 667) {
imageName = UIInterfaceOrientationIsPortrait(orientation) ? @"-800-667h@2x.png" : nil;
}
else if (mainScreenHeight == 736 || mainScreenHeight == 414) {
imageName = UIInterfaceOrientationIsPortrait(orientation) ? @"-800-Portrait-736h@3x.png" : @"-800-Landscape-736h@3x.png";
}
else {
imageName = UIInterfaceOrientationIsPortrait(orientation) ? @"-700@2x.png" : nil;
}
}
else
{
imageName = UIInterfaceOrientationIsPortrait(orientation) ? @"-700-Portrait~ipad.png" : @"-700-Landscape~ipad.png";
}
imageName = [prefix stringByAppendingString:imageName];
NSString *path = [[NSBundle mainBundle] pathForResource:imageName ofType:nil];
return [[[UIImage alloc] initWithContentsOfFile:path] autorelease];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment