Search code examples
user-interfaceroundingswiftuicornerradius

How to round specific corners of a View?


I know you can use .cornerRadius() to round all the corners of a SwiftUI view but is there a way to round only specific corners such as the top?


Solution

  • iOS 16+

    simply use UnevenRoundedRectangle

     VStack {
        UnevenRoundedRectangle(cornerRadii: .init(bottomTrailing: 50, topTrailing: 50))
                        .fill(.orange)
                        .frame(width: 200, height: 100)
     }
    

    Result:

    enter image description here