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

前端 未结 14 1563
萌比男神i
萌比男神i 2020-11-28 18:17

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 transi

14条回答
  •  旧时难觅i
    2020-11-28 18:50

    My app currently only supports iOS 7 and later.

    This is how I reference the launch image from the asset catalog:

    NSDictionary *dict = @{@"320x480" : @"LaunchImage-700",
                           @"320x568" : @"LaunchImage-700-568h",
                           @"375x667" : @"LaunchImage-800-667h",
                           @"414x736" : @"LaunchImage-800-Portrait-736h"};
    NSString *key = [NSString stringWithFormat:@"%dx%d",
        (int)[UIScreen mainScreen].bounds.size.width,
        (int)[UIScreen mainScreen].bounds.size.height];
    UIImage *launchImage = [UIImage imageNamed:dict[key]];
    

    You can add more key value pairs if you want to support older iOS versions.

提交回复
热议问题