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];
}
}
网友评论