How do you move a CALayer instantly (without animation)

前端 未结 5 1942
感情败类
感情败类 2020-12-12 12:51

I\'m trying to drag a CALayer in an iOS app.

As soon as I change its position property it tries to animate to the new position and flickers all over the

5条回答
  •  没有蜡笔的小新
    2020-12-12 13:18

    You want to wrap your call in the following:

    [CATransaction begin]; 
    [CATransaction setValue: (id) kCFBooleanTrue forKey: kCATransactionDisableActions];
    layer.position = CGPointMake(x, y);
    [CATransaction commit];
    

提交回复
热议问题