简体   繁体   中英

How to hide navigation bar correctly and elegantly in SwiftUI

It does not effectively hide the navigation bar


.navigationBarHidden(viewModel.tabNavigationHidden)
.navigationBarTitle(viewModel.tabNavigationTitle, displayMode: .inline)

To hide the navigation bar, use

view

  .navigationBarTitle("")
    .navigationBarHidden(true)

This has to be applied on every NavigationLink destination as well. For example:

NavigationLink(
    destination: OtherView()
        .navigationBarTitle("")
        .navigationBarHidden(true)
) {
    Text("Click me")
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM