Search code examples
uibezierpathcaanimationcakeyframeanimation

Two CGpaths - 1 CAAnimation - but the second path should be repeated


If I have a path which starts at the top of the screen and eases down into an oval shape. I would like to once in the oval shape for the animation to keep repeating the oval shape. How do I do this with CAKeyframeAnimations? Do I have two and delay the second? Do I wait for the first to complete and then add the second? Or is there another way?

Here my path/s

//The oval shape
UIBezierPath *trackPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(20, 100, 280, 150)];

//the curve from the top of the screen easing into the oval.
[trackPath moveToPoint:P(160, -80)];
[trackPath addCurveToPoint:P(297, 192)
    controlPoint1:P(244, 30)
    controlPoint2:P(316, 145)];

Solution

  • So I said to myself "Self.....it looks like you are going to have to answer this one yourself as nobody even wants to edit it or say that it is a duplicate......"

    One answer seems to be to create an animation with the first path. When this animation is finished use the delegate method of CAAnimation to know this, then start the second animation with the new path. The second one of course will be on repeat.