title: Draw gradient along a curved UIBezierPath
body: <p>In an app, I draw a curved UIBezierPath an an MKOverlayPathView class to show flight routes. This is the code I am using:</p>
  
  <blockquote>
  <pre><code>- (UIBezierPath *)pathForOverlayForMapRect:(MKMapRect)mapRect {
  
      ... bla bla bla ...
  
      UIBezierPath *path = [UIBezierPath bezierPath];
      [path moveToPoint:s];
      [path addQuadCurveToPoint:e controlPoint:cp1];
      [path addLineToPoint:e2];
      [path addQuadCurveToPoint:s2 controlPoint:cp2];
      [path closePath];
  
      return path;   
    }
  </code></pre>
  </blockquote>
  
  <pre><code>- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context{
  
      self.mapRect = mapRect;
  
      CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
      CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0);
      CGContextSetLineWidth(context, mapRect.size.height/700);
      CGContextSetLineJoin(context, kCGLineJoinRound);
      CGContextSetLineCap(context, kCGLineCapRound);
  
      CGContextAddPath(context, [self pathForOverlayForMapRect:mapRect].CGPath);
  
      [self updateTouchablePathForMapRect:mapRect];
  
      CGContextDrawPath(context, kCGPathFillStroke);
  
  }
  </code></pre>
  
  <p>This is working just fine but I would like to draw a gradient along that path instead of just a fill color. And this is where it is starting to get very tricky. </p>
  
  <p>I have experimented with CGContextDrawLinearGradient() but it hasn't got me anywhere useful yet.</p>