首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIBezierPath裁剪背景

UIBezierPath裁剪背景
EN

Stack Overflow用户
提问于 2013-09-18 11:08:03
回答 1查看 1.9K关注 0票数 2

我试着用一个圆的直角夹起一个直角,因为直角的宽度可以是这样的,只需要画出角的一部分。总有一个背景四舍五入。

我有以下的,填充的颜色是剪裁,但我也有一个灰色的背景剪辑。我需要做点什么才能摆脱这一切吗?

代码语言:javascript
复制
// Cell
UIBezierPath *cell = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 133, 55) cornerRadius:10];
[[UIColor greyColor] setFill];
[cell fill];

// Level
UIBezierPath *level = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 129, 55)];
[level fill];

UIBezierPath *clipPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 133, 55) cornerRadius:10];
clipPath.usesEvenOddFillRule = YES;

CGContextSaveGState(UIGraphicsGetCurrentContext()); {
    [clipPath addClip];
    [color setFill];
    [level fill];
} CGContextRestoreGState(UIGraphicsGetCurrentContext());

UIBezierPath *contact = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(135, 19, 5, 17) byRoundingCorners: UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(2.5, 2.5)];
[color setFill];
[contact fill];
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-18 12:20:22

灰色填充没有被裁剪的原因是因为它发生在剪辑被添加到上下文之前。

您在裁剪之前和之后都在执行[level fill];。在剪裁之前把它移开,它应该能工作。

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

https://stackoverflow.com/questions/18870621

复制
相关文章

相似问题

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