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
This is the (almost) complete list of the LaunchImage (excluding the iPad images with no status bar):
- (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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With