Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在ipad中按顺序播放动画_Iphone_Ipad - Fatal编程技术网

Iphone 如何在ipad中按顺序播放动画

Iphone 如何在ipad中按顺序播放动画,iphone,ipad,Iphone,Ipad,我有两个层的动画,第一层和第二层,每个层有不同的路径。所以,我想知道怎样才能按顺序演奏。首先播放第1层的动画,然后播放第2层 这是我的两个动画代码 第1层 CALayer *layer1 = [CALayer layer]; [self.layer addSublayer:layer1]; CAKeyframeAnimation *animation1 = [CAKeyframeAnimation animationWithKeyPath:@"position"];

我有两个层的动画,第一层和第二层,每个层有不同的路径。所以,我想知道怎样才能按顺序演奏。首先播放第1层的动画,然后播放第2层

这是我的两个动画代码

第1层

    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"];
第2层

    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"];

为第一个动画设置代理,并在
animationDidStop:finished:
delegate方法中启动第二个动画