Confusion of CoreAnimation: CATransaction vs CATransition vs CAAnimationGroup?

I have used these three classes several times several times.

For example, when I want to group several animations (i.e. CABasicAnimations, etc.) at the same time, first I think of CAAnimationGroup when I want to see a layer change from one state to another (i.e.: appear, etc. ) I think of CATransition . But at the same time, CATransaction designed to perform animations in batches (WTH?)

CATransaction and CATransition seem to be different animals, but do I usually see CATransitions inside CATransactions ? I read the documents several times, but they are never compared side by side and when / for what purpose they should be used.

It would be great if someone could indicate that their relationship / use :)

+4
source share
1 answer

CATransaction and CATransition really different animals ...

It seems that the missing bit in your understanding is CATransaction ; as soon as you get it, then maybe all the parts will be inserted by themselves.

A CATransaction always created every time you perform kernel animation.

Each layer modification is part of a transaction. CATransaction is the Core Animation class responsible for finalizing several modifications of the layer tree to atomic updates in the render tree.

( source )

What happens is that if you do not specify it explicitly, an implicit CATransaction will be created for you.

You can create an explicit transaction (using [CATransaction begin/commit] ) to configure several animation parameters, for example, whether to use default animations, how long they are saved, etc. All of this is described in the CATransaction link.

Explicit transactions are especially useful when setting properties of many layers at the same time (for example, when selecting several layers), temporarily disabling layer actions, or temporarily changing the duration of the resulting implied animations.

So, resuming all this, CATransaction is the "big umbrella" under which the animation of the main animation is launched, and this is the animation CABasicAnimation , CATransition or group. This allows you to set some general parameters that affect the way the animation / transition, and if you do not provide one, is used by default (implicit).

Hope this helps.

+14
source

All Articles