UIImageView *playImageV = [[UIImageView alloc] init];
[self addSubview:playImageV];
playImageV.frame = self.bounds;
// 创建图片集
NSMutableArray *imageArray = [NSMutableArray arrayWithCapacity:0];
for (NSInteger index = 1; index < 30; index++) {
NSString *image_name = [NSString stringWithFormat:@"%ld.jpg", (long)index];
UIImage *tempImage = [UIImage imageNamed:image_name];
// 添加图片
[imageArray addObject:tempImage];
}
// 播放图片集
// 设置播放的图片集(需将图片添加到数组 imageArray 中)
playImageV.animationImages = imageArray;
// 设置播放整个图片集的时间
playImageV.animationDuration = 29;
// 设置循环播放次数,默认为 0 一直循环
playImageV.animationRepeatCount = 0;
// 开始播放
[playImageV startAnimating];
// 停止播放动画
// [playImageV stopAnimating];