使用CALayer时的UIViewAnimationOptionBeginFromCurrentState等价物

Rom*_*nok 1 iphone core-animation ios

将CABasicAnimation直接添加到图层时,UIViewAnimationOptionBeginFromCurrentState标志的等效值是多少?当我为同一个键添加另一个动画并使其从当前状态开始动画时,我想要覆盖当前动画.

例如,我正在使用以下代码向我的图层添加动画.

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]; 
Run Code Online (Sandbox Code Playgroud)

任何帮助将完全赞赏.

Rob*_*ill 6

设置fromValuenil从当前表示层值开始.

从CABasicAnimation 的文档:

  • toValue是非零的.在目标图层的表示层中的keyPath的当前值和toValue之间进行插值.