我有一个可以使用CABasicAnimation旋转的using图像。当我得到一个指南针更新时,我会通过时间偏移来更改/更新图像的起始点。
这很好用,但当我从指南针获得更新并删除旧动画时,它会跳回开始位置,然后再移动到新的开始位置。这会导致闪烁效果。有没有办法同时删除和添加动画,或者以某种方式防止这种情况发生?
到目前为止,我的代码如下。
[self.waveImage.layer RemoveAllAnimations];
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.0];
animation.toValue = [NSNumber numberWithFloat:2.0 * M_PI];
animation.duration = 1.0;
animation.repeatCount = HUGE_VALF; // Repeat forever
animation.speed = 1.0/duration;
animation.timeOffset = startingPhase;
animation.fillMode = kCAFillModeForwards;
[self.waveImageView.layer addAnimation:animation forKey:@"transform.rotation.z"];发布于 2012-05-11 22:02:34
https://stackoverflow.com/questions/10552801
复制相似问题