Reputation: 99
SwiftUI reserves blank space on top of List for the title even though there is no title used.
How do i remove this space?
.navigationBarHidden() is not an option because the toolbar icons need to be shown.
Upvotes: 4
Views: 2680
Reputation: 10404
That space is associated with the NavigationView that your List is in - each view within the "stack" of the navigation's displayable views can set its own title that would then get displayed in that spot.
If you're going to keep that space unused, you can mitigate by forcing the navigation title to be in inline mode. This is what you see when you scroll down a list and the big title shrinks and moves up into the toolbar space, between the leading and trailing toolbar items.
To do this, add the .navigationBarDisplayMode
modifier to your list:
// within a NavigationView context
List {
// ...
}
.navigationBarTitleDisplayMode(.inline)
Upvotes: 1