Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
458 views
in Technique[技术] by (71.8m points)

ios fade out splash screen (iphone 5 friendly)

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?

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    if(IS_IPHONE_5)
        splash = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default-568h.png"]];
    else
        splash = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]];

    [self.window.rootViewController.view addSubview:splash];

    [UIView animateWithDuration:0.5 
                     animations:^{
                         splash.alpha = 0;
                     }
                     completion:^(BOOL finished) {
                         [splash removeFromSuperview];
                     }];
}

Then you need to define the following somewhere. I use the project .pch but you can use your header if you want.

#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...