Reputation: 672
I try to align content on top of page. It works but as soon as I add a NavigationView, it doesn't work anymore.
import SwiftUI
struct Stats: View {
var body: some View {
NavigationView { // <- OK without navigation view
VStack {
Text("Stats")
Spacer()
}
}
}
}
Seems a basic problem, but didn't succeed to work it out :( Thanks
Upvotes: 0
Views: 1317
Reputation: 672
Regards to Emilio's réponse, here is the solution.
import SwiftUI
struct Stats: View {
var body: some View {
NavigationView {
VStack {
Text("Stats")
Spacer()
}
.navigationBarHidden(true)
}
}
}
Take care to apply navigationBarHidden to the Stack and not NavigationView.
Upvotes: 2
Reputation: 94
You just need to hide NavigationBar.
NavigationView {
VStack {
Text("Stats")
Spacer()
}
.navigationBarTitle("")
.navigationBarHidden(true)
}
Upvotes: 1