In the files App after you pressed the Select button the tabBar switch to the toolbar.
How can I do this with swiftUI?(Switch between tabBar and toolbar)
struct tabBar: View {
var body: some View {
TabView {
ContentView().tabItem {
Image(systemName: "paperplane.fill")
Text("tabBar")
}
}
.toolbar {
ToolbarItem(placement: .bottomBar, content: {
Button(action: {
}){
Text("toolBar1")
}
})
ToolbarItem(placement: .bottomBar, content: {
Button() {
} label: {
Text("toolBar2")
}
})
}
}
}
For iOS 16 and above, you can use the
toolbar(_:for:)method to toggle between visible and hidden states. Also, don't forget to wrap the view in aNavigationView, or else, setting the visibility of the bottom toolbar won't work.If you have to support iOS 14 and 15, you can check every item if it should be visible and hide/show them one by one.