First could use try using toolbarBackgroundVisibility(_:for:)
to set the visibility of the background bar or toolbarBackground(_:for:)
to specify the specified style.
Now I have to set toolbar background visibility using toolbarBackground(_:for:)
via a variable along with GeometryReader
tracking y offset to make it work as I described. But I expected it to work out of the box like for any other navigation destination.
Code snippet to reproduce the issue.
NavigationStack {
List {
NavigationLink("Not TabView", value: true)
NavigationLink("TabView", value: false)
}
.navigationDestination(for: Bool.self) { value in
if value {
ScrollView {
Color.gray
.frame(height: 2000) // for scrolling to be appeared
.padding()
}
.navigationTitle("Not TabView")
.navigationBarTitleDisplayMode(.inline)
} else {
TabView {
ScrollView {
Color.gray
.frame(height: 2000) // for scrolling to be appeared
.padding()
}
.tabItem {
Label("Tab 1", systemImage: "apple.logo")
}
}
.navigationTitle("TabView")
.navigationBarTitleDisplayMode(.inline)
}
}
}