I recently started exploring the latest version of SwiftUI and encountered an issue while working with TabView and NavigationStack. I downloaded the example code provided by Apple and began making changes to explore new SwiftUI features. However, I noticed that the navigation bar "jumps" or resets when switching between tabs, even in their example implementation.
Here are some changes which I made below in the files:
LibraryView:
.navigationTitle("Library")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(Color("AccentColor"),for: .navigationBar)
WatchNowView:
.navigationTitle("Watch Now")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(Color("AccentColor"),for: .navigationBar)
example code url :- destinationVideo
I suspect the issue arises because each tab bar item has its own NavigationStack. When we set a navigation title for each view, the NavigationStack resets the navigation bar on view appearance, which causes this visual bug.
Thank you!