以编程方式加载启动图像

NSC*_*der 3 xcode ios

现在,看起来必须为launchimage.xib构建设置中的"启动屏幕文件"字段设置启动图像文件名(例如),launchimage.xib以便显示该字段.可以改为:

  • 动态加载启动图像,和/或
  • 将动作与启动图像相关联?

Gan*_*ani 8

我相信无法动态加载启动图像.但是,您可以使用以下代码访问已添加到应用程序中的启动图像.您还可以检查它是否与您的设备规模和大小匹配.

NSArray *allPngImageNames = [[NSBundle mainBundle] pathsForResourcesOfType:@"png"
                                    inDirectory:nil];

for (NSString *imgName in allPngImageNames){
// Find launch images
if ([imgName containsString:@"LaunchImage"]){
    UIImage *img = [UIImage imageNamed:imgName]; //-- this is a launch image

    // Has image same scale and dimensions as our current device's screen?
    if (img.scale == [UIScreen mainScreen].scale && CGSizeEqualToSize(img.size, [UIScreen mainScreen].bounds.size)) {
        NSLog(@"Found launch image for current device %@", img.description);
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但是我不相信这会对你有所帮助