考虑以下动画:
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1.0;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
pathAnimation.removedOnCompletion = NO;
pathAnimation.delegate = self;
这将基本上使图层的绘图从一端到另一端。问题是,一旦动画完成,strokeEnd
属性会重置回 0(最初设置的位置)。如何使最终值“坚持”?
我试图在 animationDidStop 委托方法中改变它。这主要是有效的,但strokeEnd
即使放在 CATransaction 中以禁用动画时,也会导致短暂的 0 闪烁。我也玩过additive
andcumulative
属性无济于事。有什么建议么?