I am working on a UI that combines a TabView with PageTabViewStyle, a NavigationView and a ScrollView. When scrolling down, I expect the title of the NavigationView to adjust and get smaller. But it does not when the ScrollView is placed inside the TabView. How do I implement this behavior?
This is an extension to my original question on how to use a TabView with PageTabViewStyle and a NavigationView together.
struct ContentView: View {
@State var selection = 1
var body: some View {
NavigationView {
TabView {
LibraryView()
.tag(1)
LibraryView()
.tag(2)
}
.navigationTitle(selection == 1 ? "A" : "B")
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
//.indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .always))
}
}
struct LibraryView: View {
@State var gridLayout: [GridItem] = [
GridItem(),
GridItem()
]
var body: some View {
ScrollView {
LazyVGrid(columns: gridLayout, alignment: .center, spacing: 10) {
ForEach(collections.indices) { index in
CollectionItem(collection: collections[index])
}
}
.padding(.all, 10)
}
}
}