ios fade out splash screen (iphone 5 friendly)

前端 未结 4 689
梦谈多话
梦谈多话 2020-12-16 05:29

I\'m wanting to spoof the feel of the main splash screen fading out whenever applicationDidBecomeActive is called, but it\'s not working. What am I doing wrong?

相关标签:
4条回答
  • 2020-12-16 05:48

    Your code looks about right; I do this in several apps.

    However, you want to do this as part of applicationDidFinishLaunching:options: and not in applicationDidBecomeActive:. It only makes sense to fade the splash screen when it is shown, which is only when the app is launched and not already running. When your app becomes active, it may have been in the background -- i.e. already launched -- so fading the splash screen in this case doesn't make sense.

    Or, did you want your splash screen to appear ALWAYS when it becomes active, even if it is resumed from the background from a suspended state?

    0 讨论(0)
  • 2020-12-16 05:49

    Try adding it directly to your window instead of the rootViewController.view.

    [self.window addSubview:splash];
    

    You may also need to rotate the image using view.transform to align with the startup image.

    0 讨论(0)
  • 2020-12-16 05:55

    If that is really your code, you probably have a typo in the image name. (If not, let us know what "not working" means.)

    Also, the splash screen doesn't normally come up every applicationDidBecomeActive:. didFinishLaunchingWithOptions: is the time you know that you have been launched and the splash screen had been shown on your behalf.

    0 讨论(0)
  • 2020-12-16 05:59

    I find, from ios6 you get a nice transition doing this

    -(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        [UIView animateWithDuration:0.2
                              delay:0
                            options: UIViewAnimationCurveEaseIn
                         animations:^{
                            self.window.viewForBaselineLayout.alpha = 0; // and at this alpha
                         }
                         completion:^(BOOL finished){
                         }];
    
        return YES;
    }
    

    then immediately at the start of

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    
        [UIView animateWithDuration:0.5
                              delay:0
                              options: UIViewAnimationCurveEaseOut
                          animations:^{
                             self.window.viewForBaselineLayout.alpha = 1; // and at this alpha
                         }
                         completion:^(BOOL finished){
                         }];
    

    It gives a cross fadeish effect from the loading screen to the now loaded app screen.

    0 讨论(0)
提交回复
热议问题