Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Navigation bar for `TabView` not working

In swiftUI, iOS14. I can not hide the navigation bar of TabView. Here is my code:

struct ContentView: View {
    var body: some View {
        NavigationView {
            TabView() {
                List {
                    Text("Hi!")
                    Text("How are you?")
                }
            }
            .navigationTitle("")
            .navigationBarHidden(true) // not working!!
        }
    }
}

Is this a bug? How to resolve this problem?Navigation Bar exists!

like image 420
蘇哲聖 Avatar asked Sep 15 '25 14:09

蘇哲聖


1 Answers

You need to move .navigationBarHidden(true) inside to TabView.


  struct ContentView: View {
        var body: some View {
            NavigationView {
                TabView() {
                    List {
                        Text("Hi!")
                        Text("How are you?")
                    }
                    .navigationBarHidden(true) //<= here
                }
            }
        }
    }

like image 60
Yodagama Avatar answered Sep 18 '25 08:09

Yodagama