iOS启动画面动画

Bal*_*aji 5 animation splash-screen ios

在我的应用程序中,我希望启动画面动画我正在使用以下代码,但动画无效.

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");
                }
];
Run Code Online (Sandbox Code Playgroud)

Ant*_* MG 7

您无法为启动图像设置动画,但您可以等到启动应用程序并使用动画添加自己的视图.


cod*_*cat 6

你不能不使用它会实现的一些技巧

打开AppDelegate.m并将以下代码添加到您的应用程序didFinishLaunching或application didFinishLaunchingWithOptions函数:

//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];
                 }];
Run Code Online (Sandbox Code Playgroud)

下载示例应用

动画,闪屏,默认PNG