Color filling doesn't follow the rounding in SwiftUI

1 day ago 3
ARTICLE AD BOX

I defined the following shape:

struct DisplayView: View { var body: some View { ZStack{ RoundedRectangle(cornerRadius: 20) .stroke(Color.black, lineWidth: 1) VStack{ ScrollView { VStack (spacing: 10) { ForEach (0..<30) { Text("Item \($0)") .font(.title) } } .frame(maxWidth: .infinity) }.padding() Button { print("Display list!") } label: { Text("OK") .frame(maxWidth: .infinity) .padding() .background(Color(.lightGray)) .cornerRadius(20) .padding(12) .foregroundColor(.black) .font(.title) } } } } }

…but when used in ContentView I get the following where we can see gray background over the rounding:

enter image description here

My question: how can I do it to have the color filling stop at the rounding?

Read Entire Article