Search code examples
iphonecocoa-touchcore-animationcalayer

How can I combine multiple CAKeyframeAnimations into single keyframe animation?


Say I want to combine transform

CAKeyframeAnimation *animation = [CAKeyframeAnimation
   animationWithKeyPath:@"transform"];

and opacity

CAKeyframeAnimation *animation = [CAKeyframeAnimation
   animationWithKeyPath:@"opacity"];

into keyframe animation. How do I combine and specify transform/opacity values for each keyframe?


Solution

  • Create two animations just like you do, use the same keyTimes for both of them, and add them both to the layer with addAnimation:forKey:. It's that easy.