9

I have trouble understanding apple's core animation (for iOS). I am trying to animate the position and bounds of a layer concurrently (but with different timing functions).

According to the documentation, a CAAnimationGroup allows multiple animations to be grouped and run concurrently. But according to my (early) experiments this can also be accomplished by adding several animation objects to the target layer. If so, what is the purpose of that CAAnimationGroup?

2 Answers 2

5

If you want to animate two different properties with different timing functions then grouping these animation is not needed in this case. I think that grouping is useful when you create several animations and want them to have the same timing behaviour. You can set timing function for the group. In the Core Animation Cookbook i saw an example that shows how to use grouping when setting a timing curve for CAKeyframeAnimation.

4
  • +1, but I do not understand why I shold group the animations when the timing functions are the same. Does grouping make a difference?
    – ragnarius
    Commented May 28, 2011 at 21:36
  • In case of group you don't have to watch if each of the animations in group has the proper timing function or duration, it's set once.
    – danny_23
    Commented May 28, 2011 at 21:40
  • Here is a some kind of tutorial. It's not about grouping itself, but the first code sample (Use An Interesting Animation) shows the grouping. And the duration is set to 5 seconds for the group.
    – danny_23
    Commented May 28, 2011 at 21:50
  • use grouping to ensure all animations start/end at the same time, assuming all animations have the same duration, without grouping, adding them one by one to the layer, animations will have different starting times
    – Scholle
    Commented Jan 13, 2013 at 13:05
0

The following quote is from the book "iOS Core Animation"

Adding an animation group to a layer is not fundamentally different from adding the animations individually, so it’s not immediately clear when or why you would use this class. It provides some convenience in terms of being able to collectively set animation durations, or add and remove multiple animations from a layer with a single command, but it’s usefulness only really becomes apparent when it comes to hierarchical timing , which is explained in Chapter 9 .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.