【发布时间】:2012-06-06 20:58:30
【问题描述】:
如何使用 QuartzCore 绘制带有孔的形状?
这是一个例子:
我已经知道如何绘制路径了:
CGMutablePathRef maskPath = CGPathCreateMutable();
CGPathMoveToPoint(maskPath, NULL, x1, y1);
CGPathAddLineToPoint(maskPath, NULL, x2, y2);
CGPathAddLineToPoint(maskPath, NULL, x3, y3);
CGPathCloseSubpath(maskPath);
并将其应用于 UIView:
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = viewToMask.bounds;
maskLayer.path = maskPath;
viewToMask.layer.mask = maskLayer;
但我不完全确定如何创建一条中心有一个洞的路径。 我是否需要以某种方式从路径中减去?
【问题讨论】:
-
我不确定这是否能回答我的问题。如果这是正确的做法,有人可以在这里详细说明这个答案吗?
-
也可能是 Crop a CAShapeLayer retrieving the external path 的副本,因为该形状用于在孔外放置 CAShapeLayer 蒙版
标签: objective-c cgpath quartz-core