I have a layer for a camera you can see in image 1, I need a rounded corner like image 2. How I can round it.
if cornerRadius > cornerLength { cornerRadius = cornerLength }
if cornerLength > maskContainer.width / 2 { cornerLength = maskContainer.width / 2 }
let upperLeftPoint = CGPoint(x: maskContainer.minX, y: maskContainer.minY)
let upperLeftCorner = UIBezierPath()
upperLeftCorner.move(to: upperLeftPoint.offsetBy(dx: 0, dy: cornerLength))
upperLeftCorner.addArc(withCenter: upperLeftPoint.offsetBy(dx: cornerRadius, dy: cornerRadius),
radius: cornerRadius, startAngle: .pi, endAngle: 3 * .pi / 2, clockwise: true)
upperLeftCorner.addLine(to: upperLeftPoint.offsetBy(dx: cornerLength, dy: 0))
let combinedPath = CGMutablePath()
combinedPath.addPath(upperLeftCorner.cgPath)
let cgPath = CGMutablePath()
cgPath.move(to: bottomLeftPoint)
cgPath.addArc(tangent1End: topLeftPoint, tangent2End: topRightPoint, radius: radius)
cgPath.addLine(to: topRightPoint)
let bezierPath = UIBezierPath(cgPath: cgPath)