为什么我的核心动画转换总会回到它的启动状态?

ABe*_*its 5 iphone cocoa cocoa-touch core-animation

我试图在我的iPhone应用程序中执行某种层的动画.无论我做什么,我总能得到相同的结果:动画完成后,它会回到原来的位置.即使我设置removedOnCompletion为false也没有区别.

我在这里错过了什么?

提前致谢!

编辑:这个家伙真的需要帮助.我用CAKeyframeAnimationCABasicAnimation对象创建动画,然后将它们添加到CAAnimationGroup我依次对着图层.动画按预期工作,但它总是快速恢复到原始状态.即使我设置removedOnCompletion = NO;了所有动画对象和动画组,情况也是如此.

有人请指出我正确的方向!我住在斯德哥尔摩地区,我会给你买一杯咖啡.=)以下新代码:

CABasicAnimation *leveloutLeafAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
leveloutLeafAnimation.removedOnCompletion = NO;
leveloutLeafAnimation.duration = 1.0; 
leveloutLeafAnimation.repeatDuration = 20; 
CATransform3D transformLeafToRotation = CATransform3DMakeRotation(0.0, 0.0, 0.0, 1);
CATransform3D transformLeafFromRotation = CATransform3DMakeRotation([self _degreesToRadians:270.0], 0.0, 0.0, 1);
leveloutLeafAnimation.fromValue = [NSValue valueWithCATransform3D:transformLeafFromRotation];
leveloutLeafAnimation.toValue = [NSValue valueWithCATransform3D:transformLeafToRotation];

//Create an animation group to combine the animations.
CAAnimationGroup *theAnimationGroup = [CAAnimationGroup animation];

//The animationgroup conf.
theAnimationGroup.delegate = self;
theAnimationGroup.duration = animationDuration;
theAnimationGroup.removedOnCompletion = NO;
theAnimationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
theAnimationGroup.animations = [NSArray arrayWithObjects:leveloutLeafAnimation, leafMoveAnimation, nil];

// Add the animation group to the leaf layer.
[leafViewLayer addAnimation:theAnimationGroup forKey:@"animatLeafFalling"];
Run Code Online (Sandbox Code Playgroud)

Fra*_*itt 3

不确定这是否有帮助,但这家伙似乎也遇到了类似的问题。

您可能必须transform在动画运行时将图层的属性设置为transformLeafToRotation.

祝你好运!