swiftui

Making top of navigationBar view transparent when scrolling through a List view


In my app I'm using a List() view to display a series of buttons as seen in the pictures below. When first opening the view (which lies within a NavigationStack{} view) everything looks fine (Picture 1), but the moment I start scrolling, the whitespace by the back button appears (Picture 2).

Is there a way to make this section transparent or remove it without removing the back button? enter image description here

enter image description here


Solution

  • If you're using iOS 16 and above, this should work:

    .toolbarBackground(.hidden, for: .navigationBar)