iOS开发中,LaunchImage图片会根据手机机型的不同,自动匹配对应的图片,而我们如果想要拿到对应的图片,无法直接通过图片的名字获取该启动图,而需要通过以下方式

+ (NSString *)getLaunchImageName
{
NSString *viewOrientation = @"Portrait";
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
viewOrientation = @"Landscape";
}
NSString *launchImageName = nil;
NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"]; UIWindow *currentWindow = [[UIApplication sharedApplication].windows firstObject];
CGSize viewSize = currentWindow.bounds.size;
for (NSDictionary* dict in imagesDict)
{
CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]); if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
{
launchImageName = dict[@"UILaunchImageName"];
}
}
return launchImageName;
}

这些图片的格式一般是这样子的:

LaunchImage-700-568h
LaunchImage-800-667h
LaunchImage-800-Portrait-736h
LaunchImage-700
...
05-11 20:35