Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从CGPath中修剪/减去CGPath?_Ios_Core Animation_Subtraction_Cgpath_Cashapelayer - Fatal编程技术网

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);

简短回答:不。长回答:你可以,但这很难。谢谢:)我可以通过添加图层蒙版作为后备,但我想抑制光栅化过程,我更喜欢数学。谢谢。它是在设计过程中制作的,但非常适合这个问题。:)