iOS splash Screen Animation

早过忘川 提交于 2019-11-29 10:05:32

问题


In my app I want the splash screen to be animated I'm using the following code but the animation is not working.

UIImageView *splashScreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"Default.png"]];
[self.window.rootViewController.view addSubview: splashScreen];

[self.window makeKeyAndVisible];

NSLog(@"begin splash");
[UIView animateWithDuration: 0.2
                      delay: 0.5
                    options: UIViewAnimationOptionCurveEaseOut
                animations: ^{splashScreen.alpha = 0.0;
                }
                completion: ^ (BOOL finished) {
                    [splashScreen removeFromSuperview];
                    NSLog(@"end splash");
                }
];

回答1:


You can't animate the splash image, but you can wait until the app is launched and add your own view with an animation.




回答2:


you can't but use some tricks it will achieve

Open your AppDelegate.m and add the following code to your application didFinishLaunching or application didFinishLaunchingWithOptions function:

//1. add the image to the front of the view...
UIImageView *splashImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[splashImage setImage: [UIImage imageNamed:@"Default"]];
[self.window addSubview:splashImage];
[self.window bringSubviewToFront:splashImage];

//2. set an anchor point on the image view so it opens from the left
splashImage.layer.anchorPoint = CGPointMake(0, 0.5);

//reset the image view frame
splashImage.frame = CGRectMake(0, 0, 320, 480);

//3. animate the open
[UIView animateWithDuration:1.0
                      delay:0.6
                    options:(UIViewAnimationCurveEaseOut)
                 animations:^{

                     splashImage.layer.transform = CATransform3DRotate(CATransform3DIdentity, -M_PI_2, 0, 1, 0);
                 } completion:^(BOOL finished){

                     //remove that imageview from the view
                     [splashImage removeFromSuperview];
                 }];

download sample app

animated-splash-screen-default-png



来源:https://stackoverflow.com/questions/21429346/ios-splash-screen-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!