十字のマークを描いてみた、もっと効率のよい背景透過のやり方はあるのだろうか?
class CrossDraw: UIView {
override func draw(_ rect: CGRect) {
let myRect1: UIBezierPath = UIBezierPath(roundedRect: CGRect(x: 0, y: 10, width: 30, height: 10), cornerRadius: 5)
UIColor.orange.setFill()
myRect1.fill()
let myRect2: UIBezierPath = UIBezierPath(roundedRect: CGRect(x: 10, y: 0, width: 10, height: 30), cornerRadius: 5)
UIColor.orange.setFill()
myRect2.fill()
}
}
class CrossView: UIView {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
let crossDraw = CrossDraw(frame: CGRect(x: 35, y: 35, width: 30, height: 30))
crossDraw.isOpaque = false
crossDraw.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0)
self.addSubview(crossDraw)
self.isUserInteractionEnabled = false
}
}