我见过大量的应用程序,如Sky News、Glympse等,在他们的应用程序上都有某种动画作为启动画面。
我不确定这是作为视图控制器或appdelegate中的动画完成的,还是实际的电影文件。
有人知道如何实现这种效果吗?
谢谢。
是的,动画启动画面是一个视图控制器。本教程可以帮助您创建一个。
如果要创建动画加载屏幕,可以这样做:
。H
@interface ViewController : UIViewController {
IBOutlet UIImageView *AnitmationimageView;
IBOutlet UIImageView *Loadimageview;
}
-(void)delay1;
-(void)delay2;
-(void)delay3;
.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
AnitmationimageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"L1.png"],
[UIImage imageNamed:@"L2.png"],
[UIImage imageNamed:@"L3.png"],
[UIImage imageNamed:@"L4.png"], nil];
[AnitmationimageView setAnimationRepeatCount:1];
AnitmationimageView.animationDuration = 3;
[AnitmationimageView startAnimating];
[self performSelector:@selector(delay1) withObject:nil afterDelay:3];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)delay1 {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[AnitmationimageView setAlpha:0];
[UIView commitAnimations];
[self performSelector:@selector(delay2) withObject:nil afterDelay:1.0];
}
-(void)delay2 {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[Loadimageview setAlpha:1];
[UIView commitAnimations];
[self performSelector:@selector(delay3) withObject:nil afterDelay:1.5];
}
-(void)delay3 {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[Loadimageview setAlpha:0];
[UIView commitAnimations];
}
所有这些代码都取自http://GeekyLemon.com
只需简单地,您可以通过添加全屏 imageView 并将图像数组分配给 imageView 的 animationImages 属性来做到这一点,如下所示
for(int i = 1; i < numOfImages; i++) {
[totalAnimationImages addObject:[UIImage imageNamed:
[NSString stringWithFormat:@"%@%d.png", image, i]]];
}
imageView.animationImages = totalAnimationImages;
imageView.animationDuration = 1; //speed
imageView.animationRepeatCount = 1; //infinite loop
[imageView startAnimating];