我正在尝试用圆形矩形剪裁矩形,因为矩形的宽度可能只需要绘制部分角。总会有一个背景圆角矩形。
我有以下内容,填充颜色被剪裁,但我也得到了剪裁的灰色背景。我需要做些什么来摆脱这个吗?
// 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];