您的位置:首页 > 其它

播放gif

2015-08-04 19:54 567 查看
// 播放gif图
self.tomcatImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
[self.view addSubview:self.tomcatImageView];
[self.tomcatImageView release];
// 对容器进行初始化
self.imgArr = [NSMutableArray array];
for (int i = 0; i < 26; i++) {
// 拼接图片名称
NSString *imgName = [NSString stringWithFormat:@"angry_%02d.jpg", i];
// 根据名找到相应图片
UIImage *image = [UIImage imageNamed:imgName];
[self.imgArr addObject:image];
}
// 设置播放图片的数组
self.tomcatImageView.animationImages = self.imgArr;
// 设置图片切换的时间
self.tomcatImageView.animationDuration = 1.5;
// 设置循环次数,0为最大
self.tomcatImageView.animationRepeatCount = 0;
// 开始播放
[self.tomcatImageView startAnimating];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: