I am drawing a cut-out gap in CAShapeLayer utilizing UIBezierPath, that is the code I’ve to date:
let view = UIView(
body: CGRect(origin: .zero, measurement: CGSize(width: 500.0, peak: 500.0))
)
view.backgroundColor = .clear
let shapeLayer = CAShapeLayer()
shapeLayer.body = view.bounds
shapeLayer.fillColor = UIColor.systemMint.cgColor
let mainPath = UIBezierPath(
roundedRect: CGRect(
origin: CGPoint(x: 50.0, y: 50.0), measurement: CGSize(width: 400.0, peak: 400.0)
),
cornerRadius: 10.0
)
let cutOutArc = UIBezierPath()
cutOutArc.addArc(
withCenter: CGPoint(x: 50.0, y: 250.0),
radius: 50.0,
startAngle: .pi / 2.0,
endAngle: .pi + .pi / 2.0,
clockwise: false
)
cutOutArc.addLine(to: CGPoint(x: 50.0, y: 200.0))
cutOutArc.shut()
mainPath.append(cutOutArc)
shapeLayer.fillRule = .evenOdd
shapeLayer.path = mainPath.cgPath
view.layer.insertSublayer(shapeLayer, at: 0)
(The code is simplified and tailored to make use of in Playground.)
The code outcomes on this form (seems to be precisely as I would like):

What I cannot determine easy methods to do is including a nook radius to the cut-out arc (the place the purple arrows within the picture beneath level), say, of 4.0 factors. I’ve performed with fairly random choices for a pair days now with no significant consequence. I attempted to ask AI, and it could not determine it both (it simply saved on producing damaged code actually).

Does anybody know easy methods to do it? Any steering is way appreciated!

