モーダル遷移
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