モーダル遷移

Swift

ContentView

struct ContentView: View {
    @State var isShowSecondView = false

    var body: some View {
        NavigationStack {
            VStack {
                NavigationLink {
                    SecondView()
                } label: {
                    Text("SecondViewへナビ遷移")
                }

                Button("SecondViewへモーダル遷移") {
                    isShowSecondView = true
                }
                .padding()
                .sheet(isPresented: $isShowSecondView) {
                    SecondView()
                        .presentationDetents([.medium])  <--- ハーフモーダルにできます
                }
            }
            .padding()
            .navigationTitle("画面1")
        }
    }
}

SecondView

BACK