我想从 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)
答案 0 :(得分:0)
因此,在渐变图层中添加一个遮罩层,遮住要移除的部分。