Ios 从CGPath中修剪/减去CGPath?
我在Ios 从CGPath中修剪/减去CGPath?,ios,core-animation,subtraction,cgpath,cashapelayer,Ios,Core Animation,Subtraction,Cgpath,Cashapelayer,我在CAShapeLayer上执行了一些CGPath(带两个圆的多边形) 我可以像这样修剪/减去路径吗? 不用做数学运算,而是可以在绘图时使用kCGBlendModeClear获得结果 // Create the poly. CGContextBeginPath(context); CGContextMoveToPoint (context, a_.x, a_.y); CGContextAddLineToPoint (context, b_.x, b_.y); CGContex
CAShapeLayer
上执行了一些CGPath
(带两个圆的多边形)
我可以像这样修剪/减去路径吗?
不用做数学运算,而是可以在绘图时使用
kCGBlendModeClear
获得结果
// Create the poly.
CGContextBeginPath(context);
CGContextMoveToPoint (context, a_.x, a_.y);
CGContextAddLineToPoint (context, b_.x, b_.y);
CGContextAddLineToPoint (context, c_.x, c_.y);
CGContextAddLineToPoint (context, d_.x, d_.y);
CGContextClosePath(context);
// Draw with the desired color.
CGContextSetFillColorWithColor(context, self.color.CGColor);
CGContextFillPath(context);
// Create a circle.
CGContextBeginPath(context);
CGContextAddEllipseInRect(context, (CGRect){
b_.x - self.radius,
b_.y - self.radius,
self.radius * 2.0,
self.radius * 2.0 });
CGContextClosePath(context);
// Draw with Clear (!) blend mode.
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextSetFillColorWithColor(context, self.color.CGColor);
CGContextFillPath(context);
简短回答:不。长回答:你可以,但这很难。谢谢:)我可以通过添加图层蒙版作为后备,但我想抑制光栅化过程,我更喜欢数学。谢谢。它是在设计过程中制作的,但非常适合这个问题。:)