0

So I have an app, built for iOS15, it contains a List in plainstyle which looks fine. However, running the app on an iOS 16 device (or simulator) there is now a gap that shows between sections as illusrated in the image below

enter image description here

Here's the code I've used

var body: some View {
        VStack{
            List{
                Section{
                    HStack(spacing:0){
                        Text("Some Content 1")
                            .padding(.vertical, 10)
                        Spacer()
                    }
                    .padding(.horizontal,10)
                    .listRowInsets(EdgeInsets())
                    .padding(.bottom,10)
                    .background(Color.init(Color.RGBColorSpace.sRGB, red:0.949, green:0.949, blue:0.949, opacity:1.0))
                    .listRowSeparator(.hidden)                
                } header:{
                    HStack(spacing:0){
                        Text("Header 1")
                            .font(.custom("Avenir-Heavy", size: 14))
                            .foregroundColor(Color.init(.sRGB, red: 0.11, green: 0.125, blue: 0.15, opacity: 1.0))
                            .textCase(nil)
                        Spacer()
                    }
                    .padding(10)
                    .listRowInsets(EdgeInsets())
                    .background(Color.init(Color.RGBColorSpace.sRGB, red:0.949, green:0.949, blue:0.949, opacity:1.0))
                }
                
                
                
                Section{
                    HStack(spacing:0){
                        Text("Some content 2")
                            .padding(.vertical, 10)
                        Spacer()
                    }
                    .padding(.horizontal,10)
                    .listRowInsets(EdgeInsets())
                    .padding(.bottom,10)
                    .background(Color.init(Color.RGBColorSpace.sRGB, red:0.949, green:0.949, blue:0.949, opacity:1.0))
                    .listRowSeparator(.hidden)
                    
                } header:{
                    HStack(spacing:0){
                        Text("Header 2")
                            .font(.custom("Avenir-Heavy", size: 14))
                            .foregroundColor(Color.init(.sRGB, red: 0.11, green: 0.125, blue: 0.15, opacity: 1.0))
                            .textCase(nil)
                        Spacer()
                    }
                    .padding(10)
                    .listRowInsets(EdgeInsets())
                    .background(Color.init(Color.RGBColorSpace.sRGB, red:0.949, green:0.949, blue:0.949, opacity:1.0))
                }
            }
            .listStyle(.plain)
            .background(Color.init(Color.RGBColorSpace.sRGB, red:0.949, green:0.949, blue:0.949, opacity:1.0))
            
        }
        .background(Color.init(Color.RGBColorSpace.sRGB, red:0.949, green:0.949, blue:0.949, opacity:1.0))
    }

Found a solution here - How to remove section header top padding in SwiftUI Plain List with iOS16

vsfa
  • 43
  • 4
  • Solution is here: https://stackoverflow.com/questions/73592661/how-to-remove-section-header-top-padding-in-swiftui-plain-list-with-ios16 – vsfa Oct 04 '22 at 20:40

0 Answers0