Reputation: 75
In the following tabview
a navigation bar (I mean the tabs bar etc) appears in the bottom. How to hide it? I just wanna use the tabview
as a hidden tool, I have a custom made navbar to make selection of the current tab. Removing .tabItem {Text("Home")
also does not make the bar to hide.
TabView(selection: $TabSelectedItem) {
Home()
.tabItem {
Text("Home")
}
.tag(1)
Text("Tab Content 2")
.tabItem {
Text("Tab2") }
.tag(2)
}
Upvotes: 1
Views: 1059
Reputation: 13
You can use switch
statement.
import SwiftUI
enum item {
case home
case tab2
}
struct ContentView: View {
@State var selectedItem: item = .home
var body: some View {
switch selectedItem {
case .home:
Home()
case .tab2:
Text("Tab Content 2")
}
}
}
Upvotes: 1