Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 5 & Asset Catalog: How to reference the LaunchImage?

I am using Xcode 5's Asset Catalog, and I would like to use my LaunchImage as the background image of my home view (a pretty common practice to make the transition from 'loading' to 'loaded' look smooth).

I would like to use the same entry in the Asset Catalog to save space and not have to replicate the image in two different Image Sets.

However, calling:

UIImage *image = [UIImage imageNamed:@"LaunchImage"]; //returns nil
like image 816
toblerpwn Avatar asked Oct 01 '13 03:10

toblerpwn


2 Answers

This is the (almost) complete list of the LaunchImage (excluding the iPad images with no status bar):

like image 70
Pichirichi Avatar answered Oct 19 '22 06:10

Pichirichi


- (NSString *)splashImageNameForOrientation:(UIInterfaceOrientation)orientation {
    CGSize viewSize = self.view.bounds.size;
    NSString* viewOrientation = @"Portrait";
    if (UIDeviceOrientationIsLandscape(orientation)) {
        viewSize = CGSizeMake(viewSize.height, viewSize.width);
        viewOrientation = @"Landscape";
    }

    NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
    for (NSDictionary* dict in imagesDict) {
        CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
        if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
            return dict[@"UILaunchImageName"];
    }
    return nil;
}
like image 67
Cherpak Evgeny Avatar answered Oct 19 '22 05:10

Cherpak Evgeny