\n","author":{"@type":"Person","name":"user1591668"},"upvoteCount":2,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"
That padding is a List's grouped style, if you want to remove it then use PlainListStyle
List {\n ForEach(model) { value in\n \n // Simple elements populated\n }\n }.listStyle(PlainListStyle()) // << here !!\n
\n","author":{"@type":"Person","name":"Asperi"},"upvoteCount":5}}}Reputation: 2893
I am new to swiftui and using version 2 . I have a List which populates from the database . The issue I am struggling with is getting my List to start at the very top and eliminate padding . If you look at the image below you see a gray space between the top data "Places My circle" and the list . Any help on eliminating that gray space would be great . This is my code
struct MainView: View {
@State var model: [MainModel] = []
var body: some View {
VStack {
HStack {
Text("Places")
Text("My Circle | Location")
}
TimeLineView(model: $model) // List comes from here
}
}
}
struct TimeLineView: View {
@Binding var model: [MainModel]
var body: some View {
List {
ForEach(model) { value in
// Simple elements populated
}
}.listStyle(GroupedListStyle())
.padding(0)
}
}
Upvotes: 2
Views: 764
Reputation: 258441
That padding is a List's grouped style, if you want to remove it then use PlainListStyle
List {
ForEach(model) { value in
// Simple elements populated
}
}.listStyle(PlainListStyle()) // << here !!
Upvotes: 5