SwiftUI Navigation View doesn't have enough space before content

Viewed 428

I've got a SwiftUI Navigation View and the content views inside have a very small amount of space between the navigation bar and the content. Here's my code:

struct TestView: View {

var body: some View {
    ZStack(alignment: .top) {
        NavigationView {
            List {
                Section(header: Text("Section Header")) {
                    NavigationLink(
                        destination: CustomDeckView(),
                        label: {
                            Text("A link")
                                .foregroundColor(AppTheme.Colors.text)
                        })
                    .preferredColorScheme(.light)
                }
            }
            .listStyle(InsetGroupedListStyle())
            .navigationBarTitleDisplayMode(.inline)
        }
        .navigationViewStyle(StackNavigationViewStyle())

        Text("Custom Font")
            .font(.custom("Pacifico-Regular", size: 27.5))
            .offset(y: -5)
    }
}

}

This is what it looks like in the app preview:

app preview screehshot

1 Answers

try this:

Section(header: Text("Section Header").padding(.top, 44)) {
 ....
}

or you can add it to the List.

  List {
    ....
  }.padding(.top, 44)
Related