Change splash screen image programmatically [dupli

2019-01-20 04:31发布

This question already has an answer here:

Is it allowed to set the splash screen image by code.
Since I need to change it many times ?

5条回答
成全新的幸福
2楼-- · 2019-01-20 04:48

Neah, You can't. Sorry!!!

The default image for an iphone app must be a fixed image file in your bundle. You cannot change it dynamically.

Though you can add animation to make it creative.

查看更多
狗以群分
3楼-- · 2019-01-20 04:51

When launch screen is being displayed your app will be in loading state.

Even the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions will not be completely executed while the launch screen is displayed.

So it's clear that, you don't have any access to your app and so at this point you can't execute any code.

查看更多
相关推荐>>
4楼-- · 2019-01-20 04:54

You can only load single image as Splash Screen when App Launches..

But if you want to launch any image programatically..Before App loads home screen like splash screen..you can use as below at

didFinishLaunchingWithOptions delegate method of AppDelegate..

UIImage *splashImage = [UIImage imageNamed:@"Splash_Img.png"];
    UIImageView *splashImageView = [[UIImageView alloc] initWithImage:splashImage];
    splashImageView.frame=[[UIScreen mainScreen] bounds];
    [self.window.rootViewController.view addSubview:splashImageView];
    [self.window.rootViewController.view bringSubviewToFront:splashImageView];
    [UIView animateWithDuration:1.5f
                          delay:2.0f
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         splashImageView.alpha = .0f;
                         CGFloat x = -60.0f;
                         CGFloat y = -120.0f;
                         splashImageView.frame = CGRectMake(x,
                                                            y,
                                                            splashImageView.frame.size.width-2*x,
                                                            splashImageView.frame.size.height-2*y);
                     } completion:^(BOOL finished){
                         if (finished) {
                             [splashImageView removeFromSuperview];
                         }
                     }];

Above code is not splash screen. But it loads before home screen loads.

查看更多
三岁会撩人
5楼-- · 2019-01-20 04:59

No, you cannot change Splash screen, app icon or app name programmatically.
They all stay static can't be changed.
But you can create your on custom splash using UIImageView and can change it programmatically.

查看更多
狗以群分
6楼-- · 2019-01-20 05:03

You can't.

You have to create your own splash screen displayed right after the default iOS one of your application.

查看更多
登录 后发表回答