Skip to content

Instantly share code, notes, and snippets.

@takoikatakotako
Created October 28, 2024 16:08
Show Gist options
  • Save takoikatakotako/03594e29c3a273489472756dc27a8d8b to your computer and use it in GitHub Desktop.
Save takoikatakotako/03594e29c3a273489472756dc27a8d8b to your computer and use it in GitHub Desktop.
SwiftUIでSheetを表示する
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()
}
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