0
我正在使用CAKeyframeAnimation将CALayer移动到圆形轨迹上。有时我需要停止动画并将动画移动到动画停止点。这里代码:CAKeyFrameAnimation表示层似乎不会改变
CAKeyframeAnimation* circlePathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGMutablePathRef circularPath = the circle path;
circlePathAnimation.path = circularPath;
circlePathAnimation.delegate = self;
circlePathAnimation.duration = 3.0f;
circlePathAnimation.repeatCount = 1;
circlePathAnimation.fillMode = kCAFillModeForwards;
circlePathAnimation.removedOnCompletion = NO;
circlePathAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:.43 :.78 :.69 :.99];
[circlePathAnimation setValue:layer forKey:@"animationLayer"];
[layer addAnimation:circlePathAnimation forKey:@"Rotation"];
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
CALayer *layer = [anim valueForKey:@"animationLayer"];
if (layer) {
CALayer *presentationLayer = layer.presentationLayer;
layer.position = presentationLayer.position;
}
}
但是表示层没有位置变化!!!我读到它从ios 8中不再可靠。那么有没有其他方法可以找到动画层的当前位置?
我已经获得了在iOS 8中使用表示层的动画对象的位置(实际上,frame.origin),并且它似乎工作正常。你能提供一个你读到的地方的参考,它不再可靠吗?我用presentationLayer.position对它进行了测试,结果也起作用。 – rdelmar 2015-04-05 00:24:42