I have a plus (+) sign that's currently colored in blue but I would like to make it transparent so that the user can see the background. The plus layer is added to a bigger view. Setting the plus layer to clear
color doesn't solve the problem.
class AddButtonView: UIView {
...
private func setupPlusLayer() {
let path = UIBezierPath()
path.move(to: CGPoint(x: plusButton.frame.midX, y: plusButton.frame.midY-20))
path.addLine(to: CGPoint(x: plusButton.frame.midX, y: plusButton.frame.midY+20))
path.move(to: CGPoint(x: plusButton.frame.midX-20, y: plusButton.frame.midY))
path.addLine(to: CGPoint(x: plusButton.frame.midX+20, y: plusButton.frame.midY))
path.usesEvenOddFillRule = true
let shapeLayer = CAShapeLayer()
shapeLayer.fillRule = .evenOdd
shapeLayer.path = path.cgPath
shapeLayer.strokeColor = UIColor.blue.cgColor
shapeLayer.fillColor = UIColor.blue.cgColor
shapeLayer.lineWidth = 4
// Add that `CAShapeLayer` to your view's layer:
self.layer.addSublayer(shapeLayer)
}
}
How can I make the plus sign transparent?