Is there a way to have a list in SwiftUI that has a max width in grouped style like the Settings app on an iPad Pro 12.9" ?
I have tried with something like:
and it gets me half the way. The list is centered with the max width. However, I can't set the background in a way that it covers the whole page. The List view sets its background to the system grouped background as expected for InsetGroupedListStyle. And I can wrap the list in a HStack and set a background on that. But the list even add background color up in the navigation bar, but that I cannot change. So I still can't figure out a way to do it.
I can probably accomplish what I want with just a ScrollView and make my own list. But I think that will reduce the performance?
I have tried with something like:
Code Block List { Text("Hello, world!").padding() } .frame(maxWidth: 600) .listStyle(InsetGroupedListStyle())
and it gets me half the way. The list is centered with the max width. However, I can't set the background in a way that it covers the whole page. The List view sets its background to the system grouped background as expected for InsetGroupedListStyle. And I can wrap the list in a HStack and set a background on that. But the list even add background color up in the navigation bar, but that I cannot change. So I still can't figure out a way to do it.
Code Block HStack { Spacer() List { Text("Hello, world!").padding() } .frame(maxWidth: 600) .listStyle(InsetGroupedListStyle()) Spacer() } .background(Color(UIColor.systemGroupedBackground))
I can probably accomplish what I want with just a ScrollView and make my own list. But I think that will reduce the performance?