Home > Net >  SwiftUI view with rounded corners AND border
SwiftUI view with rounded corners AND border

Time:04-05

            ZStack {
                VStack {
                    Text("some text")
                    Button("Ok") {}
                     .foregroundColor(.cyan)
                     .padding()
                }
                .padding()
            }
            .background(.red)
            .border(.blue, width: 5)
            .cornerRadius(20)

enter image description here

I want the entire view to have the blue border with rounded corners (instead of the red square overlapping the rounded blue border. How? I've tried seemingly all variations of ordering the modifiers.

CodePudding user response:

SwiftUI borders have straight edges no matter what corner radius you apply (Rounded blue border

  • Related