问题描述
我有一个带有2个标签的TabView,每个标签都包含一个NavigationView.导航到另一个视图时,我需要隐藏TabBar
.一种解决方案是将TabView
放在一个NavigationView内,但是我必须为每个NavigationView设置不同的属性.
I have a TabView with 2 tabs in it, each tab containing a NavigationView. I need to hide the TabBar
when navigating to another view. One solution would be to place the TabView
inside of one NavigationView, but I have to set different properties for each NavigationView.
TabView(selection: $selectedTab, content: {
NavigationView {
VStack {
NavigationLink(destination: Text("SecondView Tab1")) {
Text("Click")
}
}
}.tabItem {
Text("ONE")
}.tag(0)
NavigationView {
VStack {
NavigationLink(destination: Text("SecondView Tab2")) {
Text("Click")
}
}
}.tabItem {
Text("TWO")
}.tag(1)
})
P.S.我正在使用Xcode 11 Beta 5
P.S. I am using Xcode 11 Beta 5
推荐答案
有点晚了,但可以工作,将导航视图放在TabView之前,然后在选项卡式视图中使用导航链接时,将隐藏选项卡按钮.
A little late but it will work, put your NavigationView before the TabView and the tab buttons are going to be hidden when you use a navigation link in your tabbed views.
NavigationView{
TabView{
...
}
}
这篇关于在SwiftUI中使用NavigationLink导航时如何隐藏TabBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!