汤姆猫效果 - OC

  • (IBAction) drink{

    //1.把图片加载到数组中
    NSMutableArray *arrayM = [NSMutableArray array];

    for (int i = 0; i < 81; i++) {

      NSString *imgName = [NSString stringWithFormat:@"drink_%02d",i];
      
      UIImage *imgCat = [UIImage imageNamed:imgName];
      
      [arrayM addObject:imgCat];
    

    }

    //2.设置UIImageView的animationImages为对应图片合集
    self.imgViewCat.animationImages = arrayM;

    //3.动画持续时间
    self.imgViewCat.animationDuration = self.imgViewCat.animationImages.count *0.1;

    //4.重复次数
    self.imgViewCat.animationRepeatCount = 1;

    //5.启动动画
    [self.imgViewCat startAnimating];
    }

你可能感兴趣的:(汤姆猫效果 - OC)