How to draw a gradient arc with Core Graphics/iPhone?

后端 未结 3 591
感情败类
感情败类 2020-12-13 15:37

I know how to draw a arc

and I also found how to draw a gradient line from here

I have found two function can draw gradient:CGContextDrawLinearGradient and CGContex
3条回答
  •  悲&欢浪女
    2020-12-13 15:54

    You could do it by using CGContextDrawRadialGradient() with a clipping path applied. You could do something like this:

    CGContextBeginPath(context);
    CGContextMoveToPoint(context, startX, startY);
    CGContextAddArcToPoint(context, x1, y1, x2, y2, arcRadius);
    CGConextClosePath(context);
    CGContextClip(context);
    CGContextDrawRadialGradient(context, gradient, startCenter, startRadius, endCenter, endRadius, options);
    

提交回复
热议问题