1

Can anybody tell me why my views looks fine in the preview, but get pushed down in the simulator? It's super simple and very little code so I honestly have no idea what's going on. Here is my code:

import SwiftUI
import FirebaseAuth

struct MainView: View {
   @EnvironmentObject var viewModel: AppViewModel
   
   var body: some View {
      NavigationView {
         List {
            ForEach(0..<10) { _ in
               Text("Views go here")
               Text("Something else to track")
            } //: LOOP
            
         } //: LIST
         .navigationTitle("Track Stuff")
         .navigationBarItems(
            trailing: Button(action: {viewModel.signOut()}) {
               Text("Sign out")
                  .foregroundColor(buttonColor)
            }
         )
      } //: NAVIGATION
      .navigationViewStyle(StackNavigationViewStyle())
   }
}

struct MainView_Previews: PreviewProvider {
   static var previews: some View {
      MainView()
   }
}

Preview looks fine, but simulator has huge gap at top of screen

aheze
  • 24,434
  • 8
  • 68
  • 125
Ryan Kanno
  • 105
  • 8

1 Answers1

2

As mentioned by Andrew in comments, the problem arose because I had nested NavigationViews.

dbc
  • 104,963
  • 20
  • 228
  • 340
Ryan Kanno
  • 105
  • 8