iOS 启动画面动画
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21429346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS splash Screen Animation
提问by Balaji
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");
}
];
回答by Antonio MG
You can't animate the splash image, but you can wait until the app is launched and add your own view with an animation.
您无法为初始图像设置动画,但您可以等到应用程序启动并添加您自己的带有动画的视图。
回答by codercat
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:
打开您的 AppDelegate.m 并将以下代码添加到您的应用程序 didFinishLaunching 或应用程序 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];
}];