1.代码如下 (注释都有)
- (void)viewDidLoad {
[super viewDidLoad];
UIImageView * bigImageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
// 创建储存图片的数组
NSMutableArray * imageArray = [NSMutableArray array];
for (int i=1; i<19; i++)
{
// 拼接字符串图片名
NSString * imageString = [NSString stringWithFormat:@"zixun_%d",i];
// 根据图片获取图片名
UIImage * image = [UIImage imageNamed:imageString];
// 添加图片到数组
[imageArray addObject:image];
}
// gif图片组
bigImageView.animationImages = imageArray;
// 播放的速率
bigImageView.animationDuration = 3;
// 播放次数
bigImageView.animationRepeatCount = 1;
// 开始动画
[bigImageView startAnimating];
//添加子视图到view
[self.view addSubview:bigImageView];
}