I managed to draw a rect :-) But I don\'t know how to draw a rounded rect.
Can someone help me out with the following code how to round the rect?
let
override func draw(_ rect: CGRect) {
super.draw(rect)
guard let context = UIGraphicsGetCurrentContext() else { return }
context.saveGState()
defer { context.restoreGState() }
let path = UIBezierPath(
roundedRect: rect,
byRoundingCorners: [.topLeft, .topRight],
cornerRadii: CGSize(width: 4, height: 4)
)
context.addPath(path.cgPath)
context.closePath()
context.setStrokeColor(UIColor.red.cgColor)
context.strokePath()
}