从 RoundedRectangle 中删除角

remove corners from RoundedRectangle

我想创建带圆角的视图,所以我使用了 RoundedRectangle。

VStack {
        ForEach(1...10, id: \.self){_ in
            ZStack(alignment: .top) {
                RoundedRectangle(cornerRadius: 20)
                    .strokeBorder(Color(UIColor.systemGray2).opacity(0.2), lineWidth: 2)
                    .cornerRadius(20)
                    .background(Color.cell)
                    
                
                VStack {
                    Text("123123")
                    Text("123123")
                    Text("123123")
                    Text("123123")
                    Text("123123")
                }
            }
            .padding()
        }
    }
    .background(Color.gray)
}

但在这种情况下,边角不是圆角的。我怎样才能做到这一点?

可能你想要类似的东西

  ZStack(alignment: .top) {
      RoundedRectangle(cornerRadius: 20)
          .fill(Color.cell)
      RoundedRectangle(cornerRadius: 20)
          .strokeBorder(Color(UIColor.systemGray2).opacity(0.2), lineWidth: 2)
      VStack {
          Text("123123")
          Text("123123")