Reputation: 9368
What is the equivalent of UIViewAnimationOptionBeginFromCurrentState flag when adding CABasicAnimation directly to the layer? I'd want to override my current animation when I'm adding another one for the same key and make it begin animation from the current state.
E.g, I am adding animations to my layer with the following code.
CABasicAnimation *moveAnimation = [CABasicAnimation animationWithKeyPath:@"position.y"];
moveAnimation.fromValue = [NSNumber numberWithInt:layer.position.y];
moveAnimation.toValue = [NSNumber numberWithInt:0];
moveAnimation.duration = BUBBLE_DEFAULT_ANIMATION_DURATION;
[layer addAnimation:moveAnimation forKey:key];
Any help would be totally appreciated.
Upvotes: 1
Views: 944
Reputation: 13675
Set fromValue
to nil
to start from the current presentation layer value.
From the documentation for CABasicAnimation:
- toValue is non-nil. Interpolates between the current value of keyPath in the target layer’s presentation layer and toValue.
Upvotes: 6