English 中文(简体)
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"];
问题回答

暂无回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签