我正在尝试使用以下代码为UIView创建一个简单的掩码:
CAShapeLayer *mask = [CAShapeLayer layer];
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, nil, 0, 0);
CGPathAddLineToPoint(path, nil, 80, 80);
CGPathAddLineToPoint(path, nil, 0, 80);
CGPathCloseSubpath(path);
mask.path = path;
CGPathRelease(path);
self.layer.mask = mask;
除了遮罩周围的暗1像素边框外,遮罩效果很好。我解释它的最好方法是建议忽略抗锯齿,任何不完全透明的像素都被认为是不透明的。
我甚至尝试使用我想要的形状创建一个透明的.PNG,但仍会出现这个黑色边框。
有什么建议吗?