Present and Dismiss a sheet in SwiftUI

import SwiftUI
struct SheetView: View {
@State private var isShowingSheet = false
var body: some View {
Button(action: {
isShowingSheet.toggle()
})
{
Text("Show Sheet View")
}
.sheet(isPresented: $isShowingSheet,
onDismiss:didDismiss){
VStack {
Text("Welcome...")
.font(.title)
.padding(50)
Text("""
This is a Sheet View.
""")
.padding(50)
Button("Dismiss the sheet",action: {
isShowingSheet.toggle()
})
}
}
}
func didDismiss() {
// Handle the dismissing action.
}
}
struct SheetView_Previews: PreviewProvider {
static var previews: some View {
SheetView()
}
}
import SwiftUI
struct ContentView: View {
var body: some View {
SheetView()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}

Sheet with full screen cover

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store