如何更换目前推出的形象?(how to replace the current launch ima

2019-10-21 06:10发布

我想下载的图像,并将其存储在本地,当我开始我的应用程序,下一次我运行应用程序,我可以使用图像来替换目前推出的形象?

如何做到这一点?谢谢

Answer 1:

你不能做到这一点。 启动图像不意味着除非它响应设备的方向是动态的。

欲了解更多关于发布图片: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/LaunchImages.html

你能做的最好的是,在应用程序启动,使用某种很好的过渡,从你的启动图像到任何自定义图像是你下载。



Answer 2:

你可以不使用默认LaunchScreen.xib既不LaunchImage在image.xcassets因为没有执行代码的两种方式。

上次,我通过使用中间视图控制器,将出现实际的ViewController做到了。

因此,中间的ViewController将有构造是这样的:

-(instancetype)initWithMainViewController:(ViewController*)vc;

然后在viewDidLoad

-(void)viewDidLoad;
{
    [super viewDidLoad];

_imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
// assuming your downloaded image will always be stored in Documents/dynamicDefaultImage.png
NSString* downloadedImagePath =     [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"dynamicDefaultImage.png"];
    if ( [[NSFileManager defaultManager] fileExistsAtPath:downloadedImagePath] ) {
        [_imageView setImage:[UIImage imageWithContentsOfFile:downloadedImagePath]];
    } else {
    // prepare built in image in case your download failed.
        [_imageView setImage:[UIImage imageNamed:@"builtInLaunchImage"]];
    }

    // present the actual VC after certain delay
    [self performSelector:@selector(loadActualVc) withObject:nil afterDelay:1.0];
}

- (void)loadActualVc;
{
    [self presentViewController:_mainViewController animated:YES completion:^{
        // clear the image so that this VC will just be empty VC once main view controller is presented.
        [_imageView setImage:nil];
    }];
}

相比默认LaunchImage是AppDelegate中完成发射前被称为送往负载的时间是非常少的。 此外,存储器消耗将被保持在最低限度也作为一次实际视图控制器被呈现在图像被卸载。 我认为这是值得的,如果你真的有着陆页的每周/每月更新。



Answer 3:

是的,offcourse你可以改变你LunchImage

就到你的Images.xcassets文件夹中有两个选项AppIconLaunchImage ,点击LaunchImage,拖放想要的影像。

注: -要小心你滴速下来图像的大小,否则它给像一些错误The app icon set named "AppIcon" did not have any applicable content



文章来源: how to replace the current launch image?