Created
October 24, 2024 01:00
-
-
Save takoikatakotako/1fbf2df8914e9375febda007e3fac5e7 to your computer and use it in GitHub Desktop.
SwiftUIで閉じることができないモーダルを表示する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ContentView: View { | |
| @State var showingSheet = false | |
| var body: some View { | |
| Button(action: { | |
| showingSheet = true | |
| }, label: { | |
| Text("Show Modal!") | |
| }) | |
| .sheet(isPresented: $showingSheet) { | |
| ModalView() | |
| } | |
| } | |
| } | |
| #Preview { | |
| ContentView() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ModalView: View { | |
| @Environment(\.dismiss) var dismiss | |
| var body: some View { | |
| Button(action: { | |
| dismiss() | |
| }, label: { | |
| Text("Close") | |
| }) | |
| .interactiveDismissDisabled(true) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment