One of my views has a grouped List
, and I like to place a button below the final row. Here's the code:
var body: some View {
VStack() {
List {
Text("Hello World")
Text("Hello World")
Text("Hello World")
Text("Hello World")
}
.listStyle(GroupedListStyle())
Button("Button") {}
}
.navigationBarTitle("Hello World", displayMode: .inline)
}
Problem: the button always shows up at the bottom of the screen. I tried adding spacers, adding a spacing modifier to the VStack
, but the button is always at the bottom:
Instead, I'd like the button to be below the list with some spacing.
How can I do that?