views:

2045

answers:

1

I'm trying to drag a CALayer in an iPhone 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 on the iPhone.

Thanks a lot..

+20  A: 

You want to wrap your call in the following:

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

Ben Gottlieb
That's exactly it. I didn't even think of the CATransaction. Thanks a lot!
Mel
2 years later,, thanks, lol.
nacho4d