Question

Is there a way to create the following effect in Core Graphics by stroking a CGPathRef?

IMG

If it is possible, would it be more efficient to draw with Core Graphics vs. simply drawing a radial ellipse CGImageRef a whole bunch of times along the path?

Edit: to clarify: I want the central part of the stroke to be 100% opacity, and the edges to fade out from 100% opacity to 0% opacity.

Edit 2: also, I intend to use this drawing in an MKOverlayView to highlight a user's path... so not sure if a blur filter would be performant enough.

Was it helpful?

Solution

A round-capped, thick path with a shadow on it is probably the best solution for you. That would involve:

CGContextSetLineWidth()
CGContextSetLineCap()
CGContextSetShadowWithColor()

You'd want a zero offset shadow, and you'll need to experiment with the radius and blur parameters to get the effect you're after.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top