Change CABasicAnimation while its rotating iPhone

I have a uiimage that rotates using CABasicAnimation. When I get a compass update, I change / update the start point of the image with a time offset.

This works fine, but when I get the update from the compass and delete the old animation, it goes back to the beginning before moving to a new start location. This causes a flashing effect. Is there any way to remove or add animation at the same time or prevent it in some way?

My code is still below.

[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"];
+3
source share
2 answers

.

  • ofValue. fromValue,

    timePhase. . timePhase .

    . , .

    .removedOnCompletion = NO.

0

All Articles