I have this code to animate a CALayer element.
CABasicAnimation *makeBiggerAnim=[CABasicAnimation animationWithKeyPath:@"radius"];
makeBiggerAnim.duration=0.2;
makeBiggerAnim.fromValue=[NSNumber numberWithDouble:20.0];
makeBiggerAnim.toValue=[NSNumber numberWithDouble:40.0];
makeBiggerAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
My question is, now everything works fine, I would like another attribute of the same element at the same time. I've seen you can do additive animations and stuff.
My question is:
- Is the additive attribute the best / only way to do that? (animating at once multiple properties of the same object at once )
Thanks!
This is for the newest update on swift (swift 3). Your code should include a object at the end, i.e. UIButton, UILabel, something that you can animate. In my code it was the loginButton (which was the title or name).
You can create an
CAAnimationGroup
and customize the duration and timing function on it. Then you create all yourCABasicAnimations
, set their to value and add them to the animation group. Finally, you add the animation group to the layer that you are animating.Here an example:
In Swift-3 we can use CAAnimationGroup as below :-