I want to constantly rotate the layer using byValue, but I cannot get it to work correctly. I want to rotate 6 degrees per second to have a full revolution in 60 seconds.
If the initial rotation of the layer is 0, everything is in order.
The problem is that I am trying to set the initial one fromValue. If I set it fromValueto 90 degrees, the animation will rotate from 90 to 90 + 6, then jump to 90+ (90 + 6), animate and jump again.
Any idea?
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithDouble:M_PI_2];
animation.byValue = [NSNumber numberWithDouble:6.0f*M_PI/180.0f];
animation.toValue = nil;
animation.fillMode = kCAFillModeForwards;
animation.cumulative = YES;
animation.additive = NO;
animation.repeatCount = 10000;
animation.removedOnCompletion = YES;
animation.duration = 1.0;
[myLayer addAnimation:animation forKey:@"transform"];
source
share