A custom SwiftUI shape which mimics Figma's smooth corner rounding for rectangles. The smoothness value can be anyting between 0 to 100, 0 with completely circular corner radius and 100 with full smoothness. Corners to which rounding has to be applied can be specified as well. The amount of rounding can be even more than half of the smaller dimension of rectangle just like in Figma.
Article: Parametric corner smoothing in SwiftUI
Below are few examples:
SmoothRoundedRectangle(radius: 80, smoothness: .custom(100))
.fill(Color.cyan)
.frame(width: 240, height: 240)
SmoothRoundedRectangle(radius: 80, corners: [.topLeft, .bottomRight])
.fill(Color.green)
.frame(width: 240, height: 80)
SmoothRoundedRectangle(
topLeft: 80,
topRight: 20,
bottomRight: 80,
bottomLeft: 20,
smoothness: .iOS)
.frame(width: 240, height: 120)
ContentView()
.clipShape(SmoothRoundedRectangle(radius: 12, smoothness: .iOS))
The indigo corner has 60% smoothing and the green one has no smoothing.