天天看点

UIImageView动画实现

UIImageView实现动画

1、创建数组对象,把所需图片加在进数组对象中

NSMutableArray *imagesArray= [[NSMutableArray  alloc] init];

for(int i =1; i<=10;i++)

{

UIImage *image = [UIImage imageNamed:[NSSting stringWithFormat:@"%d.png",i]];

[imageArray addObject:image];

}

2、创建UIImageView对象

UIImageImage  *imageView =[ [UIImageView alloc]init];

imageView.frame = CGRectMake(60,100,50,40);//创建imageView大小

3、设置播放动画

imageView.animationImages = imageArray;

4、设置动画周期时间

imageView.animationDuration = 1;

5、设置动画播放次数

imageView.animationRepateCount = 10;

6、加载imageView进视图中

[self.window addSubview:imageView];

7、执行播放函数

[imageView startAnimating];

8、释放imageView

[imageView release];