这是导航到第二个视图的视图:
\nstruct ContentView: View {\n var body: some View {\n NavigationView {\n NavigationLink {\n SecondView()\n } label: {\n Text("Go to 2nd view")\n }\n }\n \n }\n}\n\n\n struct SecondView: View {\n var body: some View {\n ZStack {\n Color.red\n VStack {\n Text("This is a test")\n .background(.green)\n //Spacer() // <--If you add this, it pushes the Text to the top, but its background no longer respects the safe area--why is this?\n }\n }\n }\n }\nRun Code Online (Sandbox Code Playgroud)\n在第二个屏幕上,视图的绿色背景Text仅延伸到其边框,这是有道理的,因为文本是拉入视图: