如何更改CALayer的默认动画时间?

Ope*_*ead 2 iphone core-animation calayer

我使用这些代码来移动CALayer:

CGPoint position = self.position;
position.x += 10;
position.y += 10;
self.position = position;
Run Code Online (Sandbox Code Playgroud)

当我在没有任何动画调用的情况下更改图层的位置时,会有一个默认动画.当我在touchesMoved:withEvent:中使用这些代码时,这将导致图层移动滞后.

我想要做的是删除默认动画,并立即移动图层,以便它可以快速响应触摸事件,就像UIView的"中心"属性一样.

我该怎么办?特别的thx!

Dun*_*n C 9

另一张海报有正确的想法,但没有提供足够的信息.

如果要在没有动画的情况下立即更改图层属性,则需要将这些更改放在禁止操作的CATransaction中:

[CATransaction begin];
//[CATransaction setAnimationDuration: 1.0/30.0];
[CATransaction setDisableActions: TRUE];
//Put layer changes you want to take place without animation here.
[CATransaction commit];
Run Code Online (Sandbox Code Playgroud)