views:

18

answers:

1

Dear fellow Stackers,

I'm currently working on some core animation stuff for the iOS and really enjoying myself. This question is regarding the many different ways one can implement an animation. Say you would like to rotate a UIView a few times but with different timing functions for each animation cycle. To the best of my knowledge there are at least two different way of implementing this:

  1. I either create a CAAnimationGroup and add the different CABasicAnimation objects to it. By controlling their beginTime property and setting different CAMediaTimingFunction on them I get the individual behavior I want.
  2. The other option is to create a CAKeyframeAnimation and by adding different key values I can customize the different "frames" individually.

So my question is this: Is there any advantage of using either one of these implementations?

My follow up question: If so, what method do you use for finding this out? In other words, how would I go about measuring the performance of an animation?

Thank you in advance and best regards.

//Abeansits

+1  A: 

To me, the choice between the two is a semantic one:

  • If I want to animate one object over several stages, I use a keyframe animation.
  • If I want to animate several objects concurrently, I use an animation group (that can optionally consist of several keyframe animations if the animations of the single objects contain multiple stages).
Ole Begemann
ABeanSits
I don't know. But I would be surprised if the differences were in any way significant. In a low-level implementation, both should boil down to very similar code.
Ole Begemann