问题
I am drawing an arc that is an almost complete circle:
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, centerPoint.x, centerPoint.y);
CGPathAddArc(path, NULL, centerPoint.x, centerPoint.y, radius, (float)(3.0f * M_PI_2), radians, !clockwise);
CGPathCloseSubpath(path);
CGContextAddPath(context, path);
CGContextFillPath(context);
CGPathRelease(path);
I have an arc like path that is an almost complete circle. In this code it is all one color, however, I want one end to be a solid white color and the other to be a [UIColor clearColor]
so that it smoothly fades out.
Every example of code I have found uses a linear gradient. This will not work. I don't want a linear gradient, but a gradient that travels along the path so that one end is colorA and the other colorB.
It seems like this should be possible. Is it possible with CoreGraphics? Or if not, another method?
来源:https://stackoverflow.com/questions/32106853/gradient-along-a-cgpath