Created
October 28, 2024 16:08
-
-
Save takoikatakotako/03594e29c3a273489472756dc27a8d8b to your computer and use it in GitHub Desktop.
SwiftUIでSheetを表示する
This file contains 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 { | |
VStack { | |
Button(action: { | |
showingSheet = true | |
}) { | |
Text("Tap me!") | |
} | |
} | |
.sheet(isPresented: $showingSheet) { | |
Text("Sheet!!") | |
} | |
} | |
} | |
#Preview { | |
ContentView() | |
} |
This file contains 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