iPhone animation
I trying to do an animation on the iPhone and I hope someone can help me out here as I'm stumped.
I am using CAKeyframeAnimation with CAPath to animate views around.
I have these settings set:
animation.removedOnCompletion = YES;
animation.fillMode = kCAFillModeRemoved;
So that the animation is removed from the layer when the animation finishes I want the view to respond to touches. As I have found that if I set:
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
then the view no longer responds to touches after the animation.
This has also had the negative side effect of having to manually position the view to its finished location when the animation finishes.
The theory of what I'm doing works but in practice there is a jump of the view back to its original position before I can manually set its position in the animationDidStop method.
So is it possible to have the final position of animation stay and the view respond to touches?
Setting the fill mode to kCAFileModeForwards causes the animation to appear as if it is at the last step in the animation, but it is only the appearance. You actually need to set whichever property you are animating. If it's the position, you need to call:
[layer setPosition:destinationPoint];
on the layer. Then you don't have to set the fill mode or tell it not to remove the animation on completion. You will need to make sure that you set the animation for key "position" in order to override the default animation with your own. Call -setPosition before you add the animation to the layer. Something like this:
[layer setPosition:destinationPoint];
[layer addAnimation:kfAnimation forKey:@"position"];
链接地址: http://www.djcxy.com/p/74224.html
上一篇: 如何使用CAKeyframeAnimation为CATransform3D制作动画?
下一篇: iPhone动画