How to draw a gradient line (fading in/out) with Core Graphics/iPhone?
I know how to draw a simple line: CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0); CGContextMoveToPoint(context, x, y); CGContextAddLineToPoint(context, x2, y2); CGContextStrokePath(context); And I know how to do a gradient rectangle, i.g.: CGColorSpaceRef myColorspace=CGColorSpaceCreateDeviceRGB(); size_t num_locations = 2; CGFloat locations[2] = { 1.0, 0.0 }; CGFloat components[8] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; CGGradientRef myGradient = CGGradientCreateWithColorComponents(myColorspace, components, locations, num_locations); CGPoint myStartPoint, myEndPoint;