I have noticed that both the first-party Apple apps and some third-party apps are able to have search filter chips nested INSIDE the navigation bar below the titles. I am trying to figure out how one would go about achieving this.
I’ve tried to achieve this using a .toolbar
modifier however this doesn’t achieve the desired result.
Would appreciate anyones input on how one could achieve the navigation bar layouts in the screenshots using SwiftUI. That is, a native look/feel navigation bar with search, large titles, small titles, and the tags/chips/filters, exactly the same as the GitHub screenshots.
2
Answers
In the App Store app. I am assuming they are using modifier
.searchable(text: Binding<String>, placement: .navigationBarDrawer(displayMode: .always)
to show for example Search bar in the navigation bar.displayMode .always
is there just so the Searchbar is not "folding in" while scrolling, but it is always "unfolded".I hope my answer makes sense 🙂
I don’t think your samples are attached to the navigation bars. Apple introduced
PinnedScrollableViews
inThese are included in some Views such as
LazyVStack
You can set headers or footers as views that get pinned.