I am developing an application that requires the wheel to rotate around the z axis with increasing or decreasing wheel speed over time. I am using CABasicAnimation and my code is as follows. While I change the layer speed property at a certain interval, it causes a βtremblingβ wheel effect.
/ **** /
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.toValue = [NSNumber numberWithFloat:-2*M_PI]; animation.duration = 4.0f; animation.repeatCount = INFINITY; [animation setValue:@"left" forKey:@"side"]; [animation setDelegate:self]; animation.removedOnCompletion=NO; animation.fillMode = kCAFillModeForwards; animation.cumulative = YES; imageLeft.layer.beginTime = CACurrentMediaTime();
In the timer, I change the speed of the CALayer image as shown below: dPlayedPercentage is a variable.
imageLeft.layer.speed=1.0+dPlayedPercentage; [imageLeft.layer addAnimation:animation forKey:@"SpinAnimation"];
I think this is due to a position reset when changing the CALayer speed property. What should I do to fix this. Or any other way to make this animation?
Augus source share