在Images.xcassets文件下的LaunchImage、AppIcon图片名称获取方法如下:
// 获取LaunchImage图片名称
static inline NSString * launchImageName() {
CGSize screenSize = [UIScreen mainScreen].bounds.size;
NSString *viewOrientation = @"Portrait"; //默认为竖屏,横屏设置为 @"Landscape"
NSString *launchImageName = nil;
NSArray *launchImages = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
for(NSDictionary* dict in launchImages) {
CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
if(CGSizeEqualToSize(imageSize, screenSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]]) {
launchImageName = dict[@"UILaunchImageName"];
}
}
return launchImageName;
}
// 获取AppIcon图片名称
static inline NSString * appIconName() {
NSArray *iconImages = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconFiles"];
return [iconImages lastObject];
}