title: How do I further animate an image that's on a bezier path
body: <p>Maybe someone can point me in the right direction. I tried Google but dont really know how to define my question in searchable terms.</p>
  
  <p>I am animating an image along a UIBezierPath like this:</p>
  
  <pre><code>UIBezierPath *trackPath = [UIBezierPath bezierPath];
  [trackPath moveToPoint:P(8, 250)];
  [trackPath addCurveToPoint:P(318, 250)
               controlPoint1:P(156, 86)
               controlPoint2:P(166, 412)];
  [trackPath addCurveToPoint:P(652, 254)
               controlPoint1:P(488, 86)
               controlPoint2:P(512, 412)];
  [trackPath addCurveToPoint:P(992, 254)
               controlPoint1:P(818, 96)
               controlPoint2:P(872, 412)];
  
  
  CALayer *bee = [CALayer layer];
  bee.bounds = CGRectMake(0, 0, 69, 71);
  bee.position = P(160, 25);
  bee.contents = (id)([UIImage imageNamed:@"bee3.png"].CGImage);
  [self.view.layer addSublayer:bee];
  </code></pre>
  
  <p>What I want to do is animate the image itself as it moving along the path. I can animate the image when its b itself with like this:</p>
  
  <pre><code>    NSArray *blueArray = [NSArray array];
      blueArray = [[NSArray alloc] initWithObjects:
                   [UIImage imageNamed:@"blue1.png"],
                   [UIImage imageNamed:@"blue2.png"], nil];
  
      blueFly.animationImages = blueArray;
      blueFly.animationDuration = 0.20;
      blueFly.animationRepeatCount = -1;
      [blueFly startAnimating];
  </code></pre>
  
  <p>How can I combine the two, so to speak?</p>
  
  <p>Additionally I know how to draw the path itself onto the screen like this:</p>
  
  <pre><code>CAShapeLayer *beeline = [CAShapeLayer layer];
  beeline.path = trackPath.CGPath;
  beeline.strokeColor = [UIColor whiteColor].CGColor;
  beeline.fillColor = [UIColor clearColor].CGColor;
  beeline.lineWidth = 2.0;
  beeline.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:6],   [NSNumber numberWithInt:2], nil];
  [self.view.layer addSublayer:beeline];
  </code></pre>
  
  <p>But how can I draw the line only behind the image as its being animated along the path?</p>