iOS 简单动画 序列帧动画
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ NSLog(@"旭宝爱吃鱼"); UIImageView * imageView = [[UIImageView alloc]init]; NSMutableArray * animationArray = [NSMutableArray array]; for (NSInteger i = 0; i < 3; i ++) { [animationArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"animation_%02ld.jpg",(long)i]]]; } //设置动画数组 [imageView setAnimationImages:animationArray]; //设置动画播放次数 [imageView setAnimationRepeatCount:1]; //设置动画播放时间 [imageView setAnimationDuration:3*0.075]; //开始动画 [imageView startAnimating]; //动画播放完成后,清空动画数组 [imageView performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:imageView.animationDuration]; }