且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

绘制一个多边形的多边形用于描边,另一个用于填充?

更新时间:2022-12-27 14:40:50

您可以使用

CGContextDrawPath(context, kCGPathFillStroke);

而不是

CGContextFillPath(context);
CGContextStrokePath(context);

问题是 CGContextFillPath() CGContextStrokePath(上下文)
清除当前路径,以便只有第一个操作成功,第二个
操作什么都没画。 CGContextDrawPath()结合填充和描边而不用
清除其间的路径。

The problem is that both CGContextFillPath() and CGContextStrokePath(context) clear the current path, so that only the first operation succeeds, and the second operation draws nothing. CGContextDrawPath() combines fill and stroke without clearing the path in between.