我用CAShapeLayers和UIBezierPaths创建了一个可点击的图表。这些形状有背景颜色,我希望在侧面/边缘淡出透明。所有CAShapeLayers都有不同的形状。有没有办法在Swift中实现这一目标?
我附上了一个我想要做的简单示例图片:
现在,我按如下方式创建CAShapeLayers:
var path = UIBezierPath()
path.moveToPoint(CGPointMake(20, 30))
path.addLineToPoint(CGPointMake(40, 30))
path.addLineToPoint(CGPointMake(50, 60))
path.addLineToPoint(CGPointMake(120, 180))
path.closePath()
var layer = CAShapeLayer()
layer.path = path.CGPath
layer.fillColor = UIColor(red: 255, green: 0, blue: 0, alpha: 0.5).CGColor
layer.hidden = true
baseImg.layer.addSublayer(layer)
有没有办法为这些形状添加CIGaussianBlur或UIBlurEffect?