title: Animating a bezier curve point
body: <p>I'm trying to animate a bezier curve I made with Paintcode (great app, btw) and am drawing in a custom UIView in the "drawRect" method.</p>
  
  <p>The drawing works fine but I want to animate a single point in the bezier curve.</p>
  
  <p>Here's my non-working method:</p>
  
  <pre><code>-(void)animateFlame{
      NSLog(@"Animating");
      // Create the starting path. Your curved line.
      //UIBezierPath * startPath;
      // Create the end path. Your straight line.
      //UIBezierPath * endPath = [self generateFlame];
      //[endPath moveToPoint: CGPointMake(167.47, 214)];
  
      int displacementX = (((int)arc4random()%50))-25;
      int displacementY = (((int)arc4random()%30))-15;
      NSLog(@"%i %i",displacementX,displacementY);
  
      UIBezierPath* theBezierPath = [UIBezierPath bezierPath];
      [theBezierPath moveToPoint: CGPointMake(167.47, 214)];
      [theBezierPath addCurveToPoint: CGPointMake(181+displacementX, 100+displacementY) controlPoint1: CGPointMake(89.74, 214) controlPoint2: CGPointMake(192.78+displacementX, 76.52+displacementY)];
      [theBezierPath addCurveToPoint: CGPointMake(167.47, 214) controlPoint1: CGPointMake(169.22+displacementX, 123.48+displacementY) controlPoint2: CGPointMake(245.2, 214)];
      [theBezierPath closePath];
      // Create the shape layer to display and animate the line.
      CAShapeLayer * myLineShapeLayer = [[CAShapeLayer alloc] init];
  
      CABasicAnimation * pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"];
      pathAnimation.fromValue = (__bridge id)[bezierPath CGPath];
      pathAnimation.toValue = (__bridge id)[theBezierPath CGPath];
      pathAnimation.duration = 0.39f;
      [myLineShapeLayer addAnimation:pathAnimation forKey:@"pathAnimation"];
  
      bezierPath = theBezierPath;
  }
  </code></pre>
  
  <p>Using this, nothing moves on the screen at all. The random displacements generated are good and the bezierPath variable is a UIBezierPath that's declared with a class scope.</p>
  
  <p>Am I missing something? (The goal is to do a sort of candle-like animation)</p>