iOS 15 sets the TabView
's appearance depending on the loaded view's scroll position. However, this doesn't seem to update between views switched in the tab bar. How can I fix this so that the appearance updates properly?
Opening a tabbed view without scrolling content ("no-scrolling view") uses a transparent background for the tab bar.
After navigating to a tabbed view with scrolling content ("scrolling view"), a translucent background is used.
However, when coming back to the "no-scrolling view", the translucent background still remains instead of being replaced with a transparent background.
I did notice that the appearance updates properly when I open the Control Center or App Switcher and come back.
Reproduction:
enum Tab {
case scroll
case noScroll
}
struct ContentView: View {
@State var selection: Tab = .noScroll
var body: some View {
TabView(selection: $selection) {
Text("Should have a transparent tab bar")
.tabItem{ Label("No-scroll", systemImage: "xmark.circle") }
.tag(Tab.noScroll)
ScrollView {
VStack(spacing: 10) {
ForEach(0..<100) {_ in
Text("Should have a translucent tab bar")
}
}
}
.tabItem { Label("Scroll", systemImage: "circle") }
.tag(Tab.scroll)
}
}
}