Swift UI - 为 iPad 和 iPhone 设置视图

Swift UI - setting View for both iPad and iPhone

我是 Swift UI 的新手,正在编写一个简单的应用程序以供学习。我希望视图在 iPad 上看起来与在 iPhone 上看起来一样,但是 iPad 显示一个空白屏幕,其中视图刚好超出范围。我尝试按如下方式使用 GeometryReader 来修复:

var body: some View {
        NavigationView {
            GeometryReader { bounds in
                VStack(alignment: .center){
                    Text("Welcome to Fair Rent")
                        .font(Font.system(size: 30, design: .rounded))
                        .fontWeight(.bold)
                        .frame(width: nil)
                    Image(systemName: "person.3.fill")
                        .font(.largeTitle)
                        .padding(2)
                    Text("How many people do you live with?")
                        .font(Font.system(size:20, design: .rounded))
                        .multilineTextAlignment(.center)
                        .lineLimit(nil)
                        .padding(18.0)
                    NavigationLink(destination: FairRentView(viewModel: FairRentViewModel(Amounts(), housemates: 1)))
                    {
                        Text("      1 other person")
                            .styledLinkLabel(with: gradient)
                    }
                    NavigationLink(destination: FairRentView(viewModel: FairRentViewModel(Amounts(), housemates: 2)))
                    {
                        Text("      2 other people")
                            .styledLinkLabel(with: gradient)
                    }
                    NavigationLink(destination: FairRentView(viewModel: FairRentViewModel(Amounts(), housemates: 3)))
                    {
                        Text("      3 other people")
                            .styledLinkLabel(with: gradient)
                    }
                }
                .frame(width: bounds.size.width, height: bounds.size.height)
            }.navigationBarTitle("Fair Rent", displayMode: .inline)
        }
    }

有人可以在 Swift UI 中为我指明如何正确执行此操作的正确方向吗?谢谢

使用NavigationViewStyle

struct ContentView: View {
    var body: some View {
        NavigationView {
            NavigationLink(destination: DetailView()) {
                Text("Tap Me")
            }.navigationBarTitle(Text("ContentView"))
                Text("Hello, I'm a Detail View")
        }.navigationViewStyle(StackNavigationViewStyle()) 
    }
}

struct DetailView: View {
    var body: some View {
        Text("Hello, I'm a Detail View")
    }
}

iPad:

iPhone: