简体   繁体   中英

SwiftUI: How to remove spacing between 2 sections? (iOS16)

How to remove spacing between 2 sections.

在此处输入图像描述

This is my code

NavigationStack {
            List {
                Section {
                    NavigationLink( value: Color.mint) {
                        HStack {
                            Image(systemName: "person").font(.system(size: 25)).padding(.trailing)
                            Text("Hi hello").font(.anuRegular(16))
                        }.frame(minHeight: 45)
                    }
                }
                Section {
                    NavigationLink( value: Color.mint) {
                        HStack {
                            Image(systemName: "person").font(.system(size: 25)).padding(.trailing)
                            Text("Hi hello").font(.anuRegular(16))
                        }.frame(minHeight: 45)
                    }
                }
            }
            .navigationDestination(for: Color.self) { color in
               
            }
            .navigationTitle("Categories")
        }

I've tried this method below from other stacks, but it doesn't work

init() {
           UITableView.appearance().sectionFooterHeight = 0
        }

You can set the list style but then you will have to style the section cell yourself.

These two style will get rid of the space, see here for a detailed explanation about list styles

  • .listStyle(.inset)
  • .listStyle(.plain)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM