CGPath 屏蔽了 CGPoints
我正在尝试构建这个:
白色背景实际上是透明的。我知道如何将 CGPath 剪辑到设定区域,但这似乎是相反的,因为我需要从填充的 CGPath 中减去区域。
我想正确的方法是从 CGPath 中减去整个外圆,然后在我的 CGPoints 处绘制更小的圆,但我不确定如何执行前者。有人能指出我正确的方向吗?
I'm trying to build this:
Where the white background is in fact transparent. I know how to clip a CGPath to a set region, but this seems to be to other way around, since I need to substract regions from a filled CGPath.
I guess the right way to go would be to substract the whole outer-circles from the CGPath and then to draw smaller circles at my CGPoints, but I'm not sure how to execute the former. Can anyone point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我要做的:
1)绘制一般线
2)
CGContextSetBlendMode(context, kCGBlendModeClear)
在绘制时“清除上下文”。3) 绘制更大的圆圈
4)
CGContextSetBlendMode(context, kCGBlendModeNormal)
返回正常绘图5) 绘制小圆圈。
That's what I would do :
1) Draw your general line
2)
CGContextSetBlendMode(context, kCGBlendModeClear)
to "clear the context" when you draw.3) Draw you bigger circles
4)
CGContextSetBlendMode(context, kCGBlendModeNormal)
to return to normal drawing5) Draw your little circles.
您可以改为启动一个透明图层,绘制线条,然后使用透明颜色绘制较大的透明圆圈,然后绘制较小的黑色圆圈。然后,当您完成透明层时,它将准确地将您想要的内容合成回上下文中。
You could instead start a transparency layer, draw the lines, then draw the larger transparent circles using the clear color, then draw the smaller black circles. Then when you finish the transparency layer, it will composite exactly what you want back onto the context.