Skip to content

Instantly share code, notes, and snippets.

@takoikatakotako
Created October 24, 2024 01:24
Show Gist options
  • Select an option

  • Save takoikatakotako/c75e8c7865eed69144c4e305d68d1d9e to your computer and use it in GitHub Desktop.

Select an option

Save takoikatakotako/c75e8c7865eed69144c4e305d68d1d9e to your computer and use it in GitHub Desktop.
SwiftUIで全画面でSheetを表示する
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()
}
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