基础(一):UIImageView的序列帧动画


//要执行动画的图片 (数组)
@property (nullable, nonatomic, copy) NSArray *animationImages; // The array must contain UIImages. Setting hides the single image. default is nil

//要执行的时间
@property (nonatomic) NSTimeInterval animationDuration;         // for one cycle of images. default is number of images * 1/30th of a second (i.e. 30 fps)

//要执行的次数  默认是0  0是无限大的
@property (nonatomic) NSInteger      animationRepeatCount;      // 0 means infinite (default is 0)

// 判断动画的3种状态,可用于判断动画在执行中防止多次的点击 例 0 ;
//开始动画
- (void)startAnimating;
//停止动画
- (void)stopAnimating;
//是否在动画中
- (BOOL)isAnimating;

 // 0.如果当前正在动画中,就不重新执行动画
    if (self.imageView.isAnimating) return;

      //1.设置执行动画的所有图片 的数组
    self.imageView.animationImages =  arM;(数组)
    // 2.设置动画持续时间
    self.imageView.animationDuration = arrM.count * 0.1;
   
    //3.设置动画播放次数
    self.imageView.animationRepeatCount = 1;
   
    // 4.开始动画
    [self.imageView startAnimating];

你可能感兴趣的:(基础(一):UIImageView的序列帧动画)