Iphone Layer.frame在CAKeyframeAnimation后未更新?

Iphone Layer.frame在CAKeyframeAnimation后未更新?,iphone,objective-c,Iphone,Objective C,我正在尝试设置层位置的动画。它会设置动画,但其帧属性不会在动画结束时更新,似乎只有它的presentationLayer会更新。以下是我正在做的: CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint (path, NULL, layer.frame.origin.x, layer.frame.origin.y); CGPathAddLineToPoint(path, NULL, 20, 20); CGPathAd

我正在尝试设置层位置的动画。它会设置动画,但其帧属性不会在动画结束时更新,似乎只有它的presentationLayer会更新。以下是我正在做的:

CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint   (path, NULL, layer.frame.origin.x, layer.frame.origin.y);
CGPathAddLineToPoint(path, NULL, 20,  20);
CGPathAddLineToPoint(path, NULL, 20,  460);
CGPathAddLineToPoint(path, NULL, 300, 460);

CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.path = path;
animation.calculationMode = kCAAnimationPaced;
animation.repeatCount = 0;
animation.autoreverses = NO;

CAAnimationGroup *theGroup = [CAAnimationGroup animation];
theGroup.animations = [NSArray arrayWithObject:animation];
theGroup.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
theGroup.duration = 2;
theGroup.removedOnCompletion = NO;
theGroup.fillMode = kCAFillModeForwards;
CFRelease(path);

[layer addAnimation:theGroup forKey:@"animatePosition"];
动画完成后,该层位于其正确的目标位置,但当我查询其帧值时,它表示仍处于其原始位置!何时/何地/如何使frame属性与层的presentationLayer frame属性同步


感谢

动画实际上不会更改基础层上的任何值。要在最后一行之后立即更新实际帧值,只需将帧设置为新值。然后您可能可以去掉
removedOnCompletion=NO

只要动画不是相加的,动画将基于输入的数据运行,并且在动画完成之前,设置实际帧对显示没有影响