0

i'm trying to create List with GroupedListStyle. But when i provide a section without header there is empty space above the section. How to remove that empty space?

List {
            Section(header: Text("Section 1")) {
                Text("List 1 - Item 1")
                Text("List 1 - Item 2")
                Text("List 1 - Item 3")
            }
            
            Section(header: Text("Section 2")) {
                Text("List 2 - Item 1")
                Text("List 2 - Item 2")
                Text("List 2 - Item 3")
            }
        }
        .listStyle(.grouped)

I tried to provide negative padding. It working fine with ios 16+ devices. But in iOS 15 and iOS 14 negative padding is not taken. enter image description here

iroh
  • 23
  • 5
  • 1
    Does this answer your question? [SwiftUI Vertical List Section header padding in iOS 15](https://stackoverflow.com/questions/69211298/swiftui-vertical-list-section-header-padding-in-ios-15) – lazarevzubov May 17 '23 at 05:01
  • Hi @lazarevzubov, thank you for the suggestion. But I need style exactly same as grouped except the top padding. – iroh May 17 '23 at 06:39
  • How about this? https://stackoverflow.com/a/69394360/7016052 I know it's messing with UIKit again, but might work. – lazarevzubov May 18 '23 at 07:33
  • Nope, other part of my project have UIKit elements. So,i can't change the behaviour of UIKit elements – iroh May 19 '23 at 04:57

0 Answers0