使用图片组图实现GIF动画
2017-03-11 本文已影响19人
管你爱不爱
NSMutableArray *imageArr = [NSMutableArray arrayWithCapacity:4];//装图片的数组
for (int i = 0; i < 4; i++) {
NSString *imageName = [NSString stringWithFormat:@"001%d",i];
UIImage *image = [UIImage imageNamed:imageName];
[imageArr addObject:image];
}
self.girlImage.animationImages = imageArr;
self.girlImage.animationDuration = 1.5;//动画时间
self.girlImage.animationRepeatCount = 0;//重复次数,0代表无数次
dispatch_async(dispatch_get_main_queue(),^{
[self.girlImage startAnimating];//开始动画
});