Gradient ALONG a CGPath

人走茶凉 提交于 2020-01-02 06:27:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!