Created
October 24, 2024 01:24
-
-
Save takoikatakotako/c75e8c7865eed69144c4e305d68d1d9e to your computer and use it in GitHub Desktop.
SwiftUIで全画面でSheetを表示する
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 showingCover = false | |
| var body: some View { | |
| VStack { | |
| Button(action: { | |
| showingCover = true | |
| }) { | |
| Text("Tap me!") | |
| } | |
| } | |
| .frame(maxWidth: .infinity, maxHeight: .infinity) | |
| .background(Color.gray) | |
| .fullScreenCover(isPresented: $showingCover) { | |
| SecondView() | |
| } | |
| } | |
| } | |
| #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 SecondView: View { | |
| @Environment(\.dismiss) var dismiss | |
| var body: some View { | |
| VStack { | |
| Button(action: { | |
| dismiss() | |
| }) { | |
| Text("Dismiss") | |
| } | |
| } | |
| .frame(maxWidth: .infinity, maxHeight: .infinity) | |
| .background(Color.white) | |
| } | |
| } | |
| #Preview { | |
| SecondView() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment