我TabView在里面使用SwiftUI NavigationView,但我无法在iOS 13.0模拟器中隐藏导航栏。
这是代码:
import SwiftUI
struct TestView: View {
var body: some View {
ZStack {
Color.green
Text("Hello")
}
}
}
struct ContentView: View {
var body: some View {
NavigationView {
ZStack {
Color.red
TabView(selection: .constant(0),
content: {
TestView()
.tabItem { Text("test") }
.tag(0)
.navigationBarTitle("")
.navigationBarHidden(true)
})
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Run Code Online (Sandbox Code Playgroud)
有什么帮助吗?谢谢!
检查这个
TabView {
ECHomeView().tabItem {
VStack {
Text("Home")
Image.Home.renderingMode(.template)
}
}.navigationBarHidden(true)
ECMyClaimsView().tabItem {
VStack {
Text("My Claims")
Image.Myclaims.renderingMode(.template)
}
}.navigationBarHidden(true).navigationBarTitle("")
ECAddClaimView().tabItem {
VStack {
Text("Create")
Image.Create.renderingMode(.template)
}
}.navigationBarHidden(true).navigationBarTitle("")
ECMyApprovalsView().tabItem {
VStack {
Text("My Approvals")
Image.MyApprovals.renderingMode(.template)
}
}.navigationBarHidden(true).navigationBarTitle("")
ECMenuView().tabItem {
VStack {
Text("Menu")
Image.Menu.renderingMode(.template)
}
}.navigationBarHidden(true).navigationBarTitle("")
}
Run Code Online (Sandbox Code Playgroud)
Yod*_*ama -1
您已经使用 隐藏了导航栏.navigationBarHidden(true)。在这里您看到的是safe area,因此您可以使用以下命令将您的视图扩展到安全区域.ignoresSafeArea()
struct ContentView: View {
var body: some View {
NavigationView {
ZStack {
Color.red
TabView(selection: .constant(0),
content: {
TestView()
.tabItem { Text("test") }
.tag(0)
.navigationBarTitle("")
.navigationBarHidden(true)
.ignoresSafeArea() //<-here
})
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6791 次 |
| 最近记录: |