前面几篇文章基本上已经把动画说全了,但是还是丢了今天要说的这种动画,他就是UIImageView的序列帧动画.用到的最典型的例子就汤姆猫这样有趣的APP.接下来就说一下这个动画
//需要播放的序列帧图片数组(存放的是UIImage对象,会按顺序显示里面的图片)
//@property(nonatomic,copy) NSArray *animationImages;
//帧动画的持续时间
//@property(nonatomic) NSTimeInterval animationDuration;
//帧动画的执行次数(默认是无限循环)
//@property(nonatomic) NSInteger animationRepeatCount;
//开始执行帧动画
//- (void)startAnimating;
//停止执行帧动画
//- (void)stopAnimating;
//是否正在执行帧动画
//- (BOOL)isAnimating;
_loadingImageView = [[UIImageView alloc] init];
NSMutableArray *imageMutableArray = [[NSMutableArray alloc] init];
for (int i = 0; i < 93; i ++) {
NSString *imageName = [NSString stringWithFormat:@"QDArticleLoading_0%d",i];
UIImage *image = [UIImage imageNamed:imageName];
[imageMutableArray addObject:image];
}
_loadingImageView.frame = CGRectMake(100, 100, 100, 100);
_loadingImageView.animationImages = imageMutableArray;
_loadingImageView.animationDuration = 3.0;
_loadingImageView.animationRepeatCount = MAXFLOAT;
[self.view addSubview:_loadingImageView];
[self.loadingImageView startAnimating];
网友评论