Post

Replies

Boosts

Views

Activity

SwiftUI view is in the middle instead of in the top - NavigationView
I am trying to create a navigation view in SwiftUI - I want to navigate from the login form to the Home Screen. In the preview, the Home Screen is looking how it should, but on the live preview - it is centered in the middle of the screen. I tried with .navigationBarHidden(true), it goes a little bit up, but still not on the top of the screen. I also tried with a Stack and Spacer() -still the same. I think the problem is that I am using NavigationView multiple times in the code, but I am not sure how to fix it. Please help. struct ContentView: View { @EnvironmentObject var viewModel: AppViewModel var body: some View { NavigationView { if viewModel.signedIn { NavigationView { HomeScreen() } .navigationBarHidden(true) } else { SignInView() } } .onAppear { viewModel.signedIn = viewModel.isSignedIn } } }
1
0
946
Mar ’22