iPhone开发教程之利用 UIImageView 实现全屏动画的代码例子

在 iPhone 应用里加入全屏动画可以让应用更具趣味性,以下这段代码可以实现这一功能


AnimationDemoViewController.m
- (void)viewDidLoad {
[super viewDidLoad];

//指定ImageView的展示区域
UIImageView *fishAni=[UIImageView alloc] initWithFrame:[UIScreen mainScreen] bounds];

//将指定的图片载入至 animationImages
fishAni.animationImages=[NSArray arrayWithObjects:
[UIImage imageNamed:@"1.jpg"],
[UIImage imageNamed:@"2.jpg"],
[UIImage imageNamed:@"3.jpg"],
[UIImage imageNamed:@"4.jpg"],
[UIImage imageNamed:@"5.jpg"],nil ];

//设定动画播放时间
fishAni.animationDuration=1.0;

//设定重复播放次数,0 为不断重复
fishAni.animationRepeatCount=0;

//开始播放动画
[fishAni startAnimating];

//将ImageView 增加到 self.view 的 subview
[self.view addSubview:fishAni];

}

你可能感兴趣的:(iPhone开发教程之利用 UIImageView 实现全屏动画的代码例子)