Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you move a CALayer instantly (without animation)

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 place:

 layer.position = CGPointMake(x, y) 

How can I move CALayers instantly? I can't seem to get my head around the Core Animation API.

like image 897
Mel Avatar asked Oct 22 '08 15:10

Mel


1 Answers

You want to wrap your call in the following:

[CATransaction begin];  [CATransaction setValue: (id) kCFBooleanTrue forKey: kCATransactionDisableActions]; layer.position = CGPointMake(x, y); [CATransaction commit]; 
like image 173
Ben Gottlieb Avatar answered Sep 28 '22 02:09

Ben Gottlieb