CABasicAnimation * basic = [CABasicAnimation animationWithKeyPath:@"bounds"];
basic.duration = 5;
basic.fromValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 200, 200)];
basic.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 300, 300)];
CAKeyframeAnimation * keyFrame = [CAKeyframeAnimation animationWithKeyPath:@"backgroundColor"];
keyFrame.duration = 5;
keyFrame.values = @[(id)[UIColor greenColor].CGColor , (id)[UIColor blueColor].CGColor , (id)[UIColor purpleColor].CGColor , (id)[UIColor whiteColor].CGColor];
keyFrame.keyTimes = @[@(0.1),@(0.4),@(0.6),@(0.7)];
创建动画
CAAnimationGroup * gorup = [CAAnimationGroup animation];
设置组动画
gorup.animations = @[keyFrame,basic];
gorup.duration = 5;
组动画的时长 > 组中所有动画的最长时间的时候, 动画的时间以组中最长的时间为准 ,
组动画的时间 < 组中所有动画的最长时间, 动画的时间以group的时长为准
最完美: group的时长 = 组中所有动画的最长时间
添加动画
[self.changeView.layer addAnimation:gorup forKey:nil];
原文地址:http://qccccc.blog.51cto.com/6004423/1554478