代码片段 分段动画
2019-10-29 本文已影响0人
梓华
CAKeyframeAnimation *animation1 = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation1.duration = 1.6;
animation1.repeatCount = CGFLOAT_MAX;
animation1.calculationMode = kCAAnimationLinear;
animation1.values = @[[NSValue valueWithCGPoint:CGPointMake(center.x + 40, center.y)],
[NSValue valueWithCGPoint:CGPointMake(center.x + 100, center.y)],
[NSValue valueWithCGPoint:CGPointMake(center.x + 100, center.y)],
[NSValue valueWithCGPoint:CGPointMake(center.x, center.y)]];
animation1.keyTimes = @[@(0),@(0.4),@(1),@(1)];
CAKeyframeAnimation *animation2 = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
animation2.duration = 1.6;
animation2.repeatCount = CGFLOAT_MAX;
animation2.calculationMode = kCAAnimationLinear;
animation2.values = @[@1, @0, @0];
animation2.keyTimes = @[@0, @0.7, @1];
[self.extraView1.layer addAnimation:animation1 forKey:@"extraView1_animation1"];
[self.extraView2.layer addAnimation:animation1 forKey:@"extraView2_animation1"];
[self.extraView1.layer addAnimation:animation2 forKey:@"extraView1_animation2"];
[self.extraView2.layer addAnimation:animation2 forKey:@"extraView2_animation2"];