Change splash screen image programmatically [dupli

2019-01-20 04:08发布

问题:

This question already has an answer here:

  • Programmatically change splash screen in iOS? 1 answer

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

回答1:

You can't.

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



回答2:

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.



回答3:

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.



回答4:

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:

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.