【问题标题】:SwiftUi - hide "Back" button and navigation bar (appears for a fraction of second)SwiftUi - 隐藏“返回”按钮和导航栏(出现几分之一秒)
【发布时间】:2020-06-02 17:44:59
【问题描述】:

我正在使用此代码隐藏导航栏和后退按钮,但是当加载视图时,我仍然可以在几分之一秒内看到后退按钮,然后它就消失了。有什么办法可以防止它显示出来吗?

var body: some View {
    NavigationView {
        NavigationLink(destination: DeferView { WeekView(journey: self.launcher.completeJourney!) }, isActive: self.$launcher.readyJourney ) { EmptyView () }
        .navigationBarHidden(true)
        .navigationBarTitle("")
    }
}

提前谢谢你,

【问题讨论】:

    标签: swiftui navigationbar swiftui-navigationlink navigationlink


    【解决方案1】:

    也为链接目的地添加相同的修饰符,

    var body: some View {
        NavigationView {
            NavigationLink(destination: DeferView { WeekView(journey: self.launcher.completeJourney!) }
                                        .navigationBarHidden(true)   // here !!
                                        .navigationBarTitle("")      // here !!
    
                  , isActive: self.$launcher.readyJourney ) { EmptyView () }
            .navigationBarHidden(true)
            .navigationBarTitle("")
        }
    }
    

    【讨论】:

    • 这对我不起作用您还有其他建议吗?我的代码: struct FirstSwiftUIView: View { var body: some View { VStack { Text("First SwiftUi View") NavigationLink { SecondSwiftUIView() } label: { Text("Next View") } } .navigationBarBackButtonHidden(true) .navigationBarTitle( "") } }
    猜你喜欢
    • 2022-12-21
    • 1970-01-01
    • 2019-11-28
    • 1970-01-01
    • 1970-01-01
    • 2020-06-24
    • 1970-01-01
    • 1970-01-01
    • 2010-10-11
    相关资源
    最近更新 更多