Ger*_*eri 9 core-animation subtraction cashapelayer cgpath ios
我有一些CGPath(一个带有两个圆圈的聚合物)在一个上进行CAShapeLayer.
我可以修剪/减去这样的路径吗?

可以在绘图时使用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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1516 次 |
| 最近记录: |