首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >用UIBezierPath在相交路径中填充颜色

用UIBezierPath在相交路径中填充颜色
EN

Stack Overflow用户
提问于 2013-09-25 03:32:45
回答 1查看 511关注 0票数 0

我正在试着画一个里面有几个中空圆圈的视图。视图的背景颜色将是黑色的,不透明度为0.5,在我可以看到它下面的视图的地方有中空的圆圈。这在下面的代码中工作得很好,但当我的空心圆圈相交时有一个问题,我想把它们都作为空心区域覆盖,但由于奇偶规则,这是不能解决的。有什么建议吗?或者其他选择?

代码语言:javascript
运行
AI代码解释
复制
- (void)addShadowView {
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height) cornerRadius:0];

    for (NSValue *point in self.hollowFrames) {
        UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(point.CGPointValue.x - self.hollowCircleRadius.floatValue, point.CGPointValue.y - self.hollowCircleRadius.floatValue, 2.0 * self.hollowCircleRadius.floatValue, 2.0 * self.hollowCircleRadius.floatValue) cornerRadius:self.hollowCircleRadius.floatValue];

        [path appendPath:circlePath];
    }

    [path setUsesEvenOddFillRule:YES];

    CAShapeLayer *fillLayer = [CAShapeLayer layer];
    fillLayer.path = path.CGPath;
    fillLayer.fillRule = kCAFillRuleEvenOdd;
    fillLayer.fillColor = [UIColor blackColor].CGColor;
    fillLayer.opacity = 0.5;
    [self.layer addSublayer:fillLayer];
}

这就是它现在的样子。我希望相交的区域也是中空的,而不是用fillColor填充。

EN

回答 1

Stack Overflow用户

发布于 2013-09-25 03:50:20

不要填满圆圈,把中心剪掉。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18995742

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档