超简单一个方法实现播放动画
查看次数:2507
下载次数:244
上传时间:2018-04-21
大小:1001 B
代码比较大 请移步github : https://github.com/shabake/GHProject
- (void)playAnimateWithName:(NSString *)name framesNumber:(int)frames {
// 动画可能被打断
if (self.imageView.isAnimating) {
return;
}
// 1.取出所有的这个动画相关的序列图片,生成一个数组用来存放这些图片
// 1.1生成数组
NSMutableArray *array = [NSMutableArray array];
// 1.2循环生成图片名,根据图片名把图片存入数组
for (int i = 0; i < frames; i++) {
NSString *string = [NSString stringWithFormat:@"eat_d", i];
// 生成图片
UIImage *image = [UIImage imageNamed:string];
// 将图片加入数组
[array addObject:image];
}
// 1.3把数组存入UIImageView中 self.imageView.animati
// 1.4 option self.imageView.animati
// fps 12 self.imageView.animati / 12;
// 1.5播放动画
[self.imageView startAnimating];
// self.animationImageView.animati
[self.imageView performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.imageView.animationDuration];
}
收藏