I have one such:
CALayer *layer = stripeButton.layer;
CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"bounds.origin.y"];
moveAnim.duration = 3.35;
moveAnim.repeatCount = 0;
moveAnim.autoreverses = NO;
moveAnim.removedOnCompletion = NO;
moveAnim.calculationMode = kCAAnimationLinear;
moveAnim.fillMode = kCAFillModeForwards;
[theLayer addAnimation:moveAnim forKey:@"theAnimation"];
You see that this animation lasts 3.35 seconds. Meanwhile, it may happen that after 2 seconds a new animation with the same key @ "theAnimation" will be launched for different values.
The problem is what happens: the new animation does not display the current visible state. It starts from scratch. The view goes to its original position in an ugly manner, and from there a new animation begins. For UIView, there is setAnimationsBeginFromCurrentState = YES, but I did not find anything similar for CAKeyFrameAnimation. Any idea?
HelloMoon
source
share