2

I have been trying to draw a gradient on a path similar to how it is done in the image below using either CALayers or CGContexts.

The path does not need to have a variable thickness or outline. It just needs the gradient on the path.

Path Gradient
(source: sethtaylor.com)

I have been using the solution in the following answer Draw gradient along a curved UIBezierPath when my line was near straight. Now the line curves back on itself like in the image above and needs the stroke to be drawn along the path programmatically.

I am not quite sure where to start looking for this. What would you try?

Community
  • 1
  • 1
Pruthvikar
  • 430
  • 4
  • 15

1 Answers1

0

@saniul on Twitter pointed out to Gradient Polyline with MapKit ios, which has the code for stepping through a path and drawing each segment differently. Should have all the building blocks you need!

Community
  • 1
  • 1
nevyn
  • 7,052
  • 3
  • 32
  • 43