// 创建数组缓存图片用来动画
- (NSArray*)ImgArray{
if(!_ImgArray) {
_ImgArray= [NSArray arrayWithObjects:
[UIImage imageNamed:@"camerairs1"],
[UIImage imageNamed:@"camerairs2"],
[UIImage imageNamed:@"camerairs3"],
[UIImage imageNamed:@"camerairs4"],
[UIImage imageNamed:@"camerairs5"],
[UIImage imageNamed:@"camerairs6"],
[UIImage imageNamed:@"camerairs7"],
[UIImage imageNamed:@"camerairs8"],
[UIImage imageNamed:@"camerairs9"],
[UIImage imageNamed:@"camerairs10"],
[UIImage imageNamed:@"camerairs11"],
[UIImage imageNamed:@"camerairs12"],
[UIImage imageNamed:@"camerairs13"],
[UIImage imageNamed:@"camerairs14"],
[UIImage imageNamed:@"camerairs15"],
[UIImage imageNamed:@"camerairs16"],
[UIImage imageNamed:@"camerairs17"],nil];
}
return_ImgArray;
}
// 创建photoImgV来动画播放图片
photoImgV= [[UIImageView alloc] initWithFrame:self.view.frame];
photoImgV.animationImages=self.ImgArray;
[photoImgV setAnimationDuration:0.5];//设置动画时间
[photoImgV setAnimationRepeatCount:0];//设置重复次数
// 开始播放(因为在我的项目中事拍照动画,第一次拍照会阻塞,按钮很久才会弹起,所以加了异步)
dispatch_async(dispatch_get_main_queue(), ^{
[photoImgV startAnimating];
});
// 停止动画
[photoImgV stopAnimating];
注:不喜勿喷!!!