How to play animation in order in ipad

Posted by juliet on Stack Overflow See other posts from Stack Overflow or by juliet
Published on 2011-01-01T10:44:40Z Indexed on 2011/01/01 10:53 UTC
Read the original article Hit count: 280

Filed under:
|

I have two animations for two layers, layer1 and layer2, each has different path. So, I want to know how can play them in order. first play layer1's animation, and then layer2.

here is my two animation code!

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

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ipad