Hy together,
please see enclosed test code which shows the result in the attached screen shot.
import SwiftUI
struct ContentView: View {
@State var tabIndex = 0
var body: some View {
TabView(selection: $tabIndex) {
HomeView()
.tabItem {
Label("Home", systemImage: "house")
}
.tag(0)
TestView()
.tabItem {
Label("Schedule", systemImage: "calendar")
}
.tag(1)
}
// end of TabView
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct HomeView: View {
var body: some View {
VStack {
Text("HomeView")
.font(.title)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(LinearGradient(gradient: Gradient(colors: [.white, Color.blue]), startPoint: .top, endPoint: .bottom))
}
}
}
struct TestView: View {
var body: some View {
VStack (alignment: .leading) {
Text("TestView")
.font(.title)
}
}
}
I wanted to achieve, that the TabBar has the iOS default background color and differentiates to the rendered background. Or in other words, why does max height: .infinity renders the safe area too?
Next question: is there an easy way to switch the TabBar ON and OFF?
Thanks