Iphone 如何更换CALayer';默认动画时间是多少?
我使用以下代码移动CALayer:Iphone 如何更换CALayer';默认动画时间是多少?,iphone,core-animation,calayer,Iphone,Core Animation,Calayer,我使用以下代码移动CALayer: CGPoint position = self.position; position.x += 10; position.y += 10; self.position = position; 当我在没有任何动画调用的情况下更改层的位置时,会出现默认动画。当我在TouchsMoved:withEvent:中使用这些代码时,这将导致层移动延迟 我想做的是删除默认动画,并立即移动层,以便它能够快速响应触摸事件,就像UIView的“中心”属性一样 我该怎么办?特价t
CGPoint position = self.position;
position.x += 10;
position.y += 10;
self.position = position;
当我在没有任何动画调用的情况下更改层的位置时,会出现默认动画。当我在TouchsMoved:withEvent:中使用这些代码时,这将导致层移动延迟
我想做的是删除默认动画,并立即移动层,以便它能够快速响应触摸事件,就像UIView的“中心”属性一样
我该怎么办?特价thx 简单设置
[CATransaction setDisableActions:YES];
这将使图层无延迟地移动另一张海报的想法是正确的,但没有提供足够的信息 如果要立即更改图层特性而不使用动画,则需要将这些更改放在CATTransaction中,在CATTransaction中禁用操作:
[CATransaction begin];
//[CATransaction setAnimationDuration: 1.0/30.0];
[CATransaction setDisableActions: TRUE];
//Put layer changes you want to take place without animation here.
[CATransaction commit];
如果我们不想要任何动画,为什么要设置非零动画持续时间的可能重复?因为我在键入答案之前没有充分考虑它。你说得对,持续时间没有意义。(我在回答中指出了这一点。谢谢你指出。)