我想从CAshapelayer中裁剪出红色三角形部分。

这是我用来绘制的代码:

Radial Gradient background in Swift,我的代码是:

let bgLayer = RadialGradientLayer(center: speed_dial_center_point, radius: speed_dial_size.width/2, colors: [UIColor.clear.cgColor,UIColor(red: 211/255, green: 211/255, blue: 211/255, alpha: 0.5).cgColor],speed_scale_margin: speed_scale_margin)//CALayer()
            bgLayer.frame = CGRect(origin: rect.origin, size: speed_dial_size)
            bgLayer.contentsScale = self.layer.contentsScale
            bgLayer.setNeedsDisplay()
            backgondArc_Layer.addSublayer(bgLayer)
            self.layer.insertSublayer(backgondArc_Layer, below: speed_dial_layer)

最佳答案

因此,在渐变层中添加一个遮罩层,以遮罩要删除的部分。

10-08 03:14