CoreGraphics FillPath And Stroke Path

喜夏-厌秋 提交于 2019-12-03 04:46:24

Try

CGContextDrawPath(context, kCGPathFillStroke);

Instead of

CGContextStrokePath(context);
CGContextFillPath(context);

Either use

CGContextDrawPath(context, kCGPathFillStroke);

as sch suggested, or draw the hexagon again before calling FillPath. StrokePath and FillPath remove the path that you have added to the context, thus the next call will silently fail without a path.

CGPathRef path = /* drawing hexagon here */;
CGContextAddPath(context, path);
CGContextStrokePath(context);
CGContextAddPath(context, path);
CGContextFillPath(context);

Note: the two segments of code are not equivalent and gives different result.

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