I have a background applied to my ContentView. That works great. No surprise there.
I have a TabView. Each tab should either be able to have its own fullscreen background or they should have a transparent background so that the main background can be seen, buuuuut no.
What happens is that the tabs cannot occupy the full screen, and if they do, I still want to see the tab bar.
Basically, I want to apply a single background, and have it visible no matter which tab is selected by the user.
Seems straightforward, but I cannot make it work.
Here’s the code:
import Foundation
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack {
BackgroundImageView()
.ignoresSafeArea()
VStack{
TabView {
HomeView()
.background(Color.clear)
.tabItem {
Image(systemName: "house.fill")
.imageScale(.large)
}
ListingView()
.background(Color.clear)
.tabItem {
Image(systemName: "clipboard.fill")
.imageScale(.large)
}
SettingsView()
.background(Color.clear)
.tabItem {
Image(systemName: "gearshape.fill")
.imageScale(.large
}
}
}
.padding()
}
}
}
struct HomeView: View {
var body: some View {
VStack {
Spacer()
Text("Home")
Spacer()
}
.background(Color.clear)
}
}
How it renders is that I can see that the background image is fullscreen, but the HomeView renders a large rectangle (black in dark mode) with the “Home” text in the center, and a tab bar.
The other tabs exhibit the same behavior.
I’m sure that it’s something simple that I’m missing.
ArchTx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.