Hello,
I seem to be unable to change TabView's background color (not the bar, but the background of the entire TabView), no matter what I try.
What I am looking for:
- To make the TabView's background clear.
My code:
TabView(selection: $activeScreen) {
Screen1()
.tabItem {
Label("Menu", systemImage: "list.dash")
}
}
Screen1 is defined as:
struct Screen1: View {
var body: some View {
VStack {
Text("Hello")
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
What I have tried, based on suggestions online:
- Changing UITabBarAppearance in init(), and .onAppear()
- TabView().background(.clear)
In all cases, the TabView's background remains either white or black, depending on the device's theme. I can change the background behind it by placing it in a ZStack, but that is not what I am looking for, I want the background itself to be clear.
The only way that TabView will honor .background(.clear) is if I add the following:
.tabViewStyle(.page)
.indexViewStyle(.page(backgroundDisplayMode: .always))
But this changes the style of the TabView, which is not the desired behavior.
Any help would be greatly appreciated, thank you!