У меня есть две анимации для двух слоев, layer1 и layer2, каждая из которых имеет свой путь. Итак, я хочу знать, как можно сыграть их по порядку. сначала запустите анимацию layer1, а затем layer2.
вот мои два кода анимации!
layer1
CALayer *layer1 = [CALayer layer];
[self.layer addSublayer:layer1];
CAKeyframeAnimation *animation1 = [CAKeyframeAnimation animationWithKeyPath:@"position"];
layer1.contents = (id)image1.CGImage;
layer1.anchorPoint = CGPointZero;
layer1.frame = CGRectMake(0.0f, 0.0f, image1.size.width, image1.size.height);
animation1.path = path1;
animation1.duration = 2.0f;
animation1.calculationMode = kCAAnimationLinear;
[layer1 addAnimation:animation1 forKey:@"position"];
layer2
CALayer *layer2 = [CALayer layer];
[self.layer addSublayer:layer2];
CAKeyframeAnimation *animation2 = [CAKeyframeAnimation animationWithKeyPath:@"position"];
layer2.contents = (id)image2.CGImage;
layer2.anchorPoint = CGPointZero;
layer2.frame = CGRectMake(0.0f, 0.0f, image2.size.width, image2.size.height);
animation2.path = path2;
animation2.duration = 2.0f;
animation2.calculationMode = kCAAnimationLinear;
[layer2 addAnimation:animation2 forKey:@"position"];