【问题标题】:Hidden Navbar still pushes down view隐藏的导航栏仍然会向下推视图
【发布时间】:2020-05-10 14:01:45
【问题描述】:

我有一个:

contentView()
SignUpView()
SignInView()

contentView 调用SignInView()

struct ContentView: View {

    var body: some View {
        NavigationView {
            SignInView()
        }
    }
}

在我的 SignUpView() 中,我有:

var body: some View {
    VStack(alignment: .leading) {
       NavigationLink(destination: SignInView()) {
          Text("Sign in")
            .fontWeight(.semibold)
            .foregroundColor(Color("startColor"))
        }
   }.navigationBarHidden(true)

在我的 SigbInView 中,我有:

var body: some View {
  VStack(alignment: .leading) {
    NavigationLink(destination: SignUpView()) {
       Text("Sign up")
       .fontWeight(.semibold)
       .foregroundColor(Color("startColor"))
     }.navigationBarHidden(true)

我使用.navigationBarHidden(true) 隐藏栏,但< back 仍然出现在左上角带您回到上一个屏幕,我还尝试添加导航栏text = "" 并将属性设置为@ 987654329@

我试图仅在 SignInView 和 SignUpViews 上使用这些 navigationLinks 进行导航,我不希望栏出现或将视图向下推。

【问题讨论】:

  • 我想你在错误的地方使用了.navigationBarHidden(true),它运作良好。它应该在 NavigationView 中。
  • @Asperi,刚刚更新了我的问题以显示更多代码

标签: swiftui swiftui-navigationlink


【解决方案1】:

所以看起来另一个属性可以设置为true来隐藏后退按钮:

.navigationBarBackButtonHidden(true)

这对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-14
    • 1970-01-01
    相关资源
    最近更新 更多