Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SwiftUIでのModalの扱い方
import SwiftUI
struct ContentView: View {
@State var showModal = false
var body: some View {
Button(action: {
self.showModal.toggle()
}) {
Text("次のViewへ")
}
.sheet(isPresented: self.$showModal) {
NextView()
}
}
}
struct NextView: View {
@Environment(\.presentationMode) var presentationMode
var body: some View {
NavigationView {
Text("これはNextViewです")
.navigationBarTitle("NextView",displayMode: .inline)
.navigationBarItems(leading: Button("完了") {
self.presentationMode.wrappedValue.dismiss()
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.