美文网首页
UITableView重用机制导致CABasicAnimatio

UITableView重用机制导致CABasicAnimatio

作者: RWN4444 | 来源:发表于2019-12-13 15:08 被阅读0次

    1.添加动画的代码

    - (void) rotateViewAnimated{
        CABasicAnimation *rotateYBasAni = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
        rotateYBasAni.duration = animationTime;
        rotateYBasAni.fromValue = @(0);
        rotateYBasAni.toValue = @(M_PI * 2.0);
        rotateYBasAni.repeatCount = HUGE_VALF;
        rotateYBasAni.removedOnCompletion = NO;
        rotateYBasAni.fillMode = kCAFillModeForwards;
        rotateYBasAni.delegate = self;
        rotateYBasAni.autoreverses = YES;
        // 1秒后执行
    //    rotateYBasAni.beginTime = CACurrentMediaTime() + .25;
        [self.oneCS.layer addAnimation:rotateYBasAni forKey:@"rotation.y"];
        
    }
    

    解决办法:刷新的时候判断动画还有没有,没有的话重新加上动画 在setmodel里填写

    -(void)setModel:(HLInviteModel *)model{
        _model = model;
       ///其他的赋值逻辑
        NSArray * array = self.oneCS.layer.animationKeys;
         if (![array containsObject:@"rotation.y"]) {
                [self rotateViewAnimated];
           }
    }
    
    

    相关文章

      网友评论

          本文标题:UITableView重用机制导致CABasicAnimatio

          本文链接:https://www.haomeiwen.com/subject/krvfnctx.html