【发布时间】:2012-05-11 13:57:15
【问题描述】:
我有一个使用 CABasicAnimation 旋转的 uiimage。当我获得指南针更新时,我会按时间偏移量更改/更新图像起点。
这很好用,但是当我从指南针获取更新并删除旧动画时,它会跳回到起点,然后再移动到新的起点位置。这会导致闪烁效果。是否可以同时删除和添加动画或以某种方式防止这种情况发生?
到目前为止我的代码如下。
[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"];
【问题讨论】:
标签: iphone ios animation layer cabasicanimation