Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable CALayer implicit animations?

It's driving me crazy! I am working on a drawing application. Let's say I am working on a UIView called sheet.

I am adding some sublayers to this view ([sheet.layer addSublayer:...]) and then I want to draw into them. To do so I am creating a CGImageRef and putting it into the layer's contents. But it's animated and I don't want that.

I tried everything:

  • removeAnimationForKey:
  • removeAllAnimations
  • set the actions dictionary
  • using the actionlayer delegate
  • [CATransaction setDisableAnimations:YES]

It's seems correct. I don't understand why this layer is still animated ;_;
Am I doing something wrong? Is there a secret way?

like image 608
Esepher Avatar asked Apr 29 '11 14:04

Esepher


People also ask

What is layer Swift?

Overview. Layers are often used to provide the backing store for views but can also be used without a view to display content. A layer's main job is to manage the visual content that you provide but the layer itself has visual attributes that can be set, such as a background color, border, and shadow.


1 Answers

Swift

CATransaction.begin() CATransaction.setDisableActions(true)  // change layer properties that you don't want to animate  CATransaction.commit() 
like image 72
Suragch Avatar answered Sep 27 '22 22:09

Suragch