struct ContentView: View { @State private var presentSheet = false var body: some View { VStack { Text("DevTechie!") .font(.largeTitle) .foregroundColor(.primary) Button("Show Sheet") { presentSheet.toggle() } .buttonStyle(.borderedProminent) .sheet(isPresented: $presentSheet) { Text("This is a bottom sheet") .presentationDetents([.medium]) } } .padding() } }
Note that presentationDetents modifier is applied inside the Sheet view on the Sheet view.
struct ContentView: View { @State private var presentSheet = false var body: some View { VStack { Text("DevTechie!") .font(.largeTitle) .foregroundColor(.primary) Button("Show Sheet") { presentSheet.toggle() } .buttonStyle(.borderedProminent) .sheet(isPresented: $presentSheet) { Text("This is a bottom sheet") .presentationDetents([.large, .medium]) } } .padding() } }
struct ContentView: View { @State private var presentSheet = false var body: some View { VStack { Text("DevTechie!") .font(.largeTitle) .foregroundColor(.primary) Button("Show Sheet") { presentSheet.toggle() } .buttonStyle(.borderedProminent) .sheet(isPresented: $presentSheet) { Text("This is a bottom sheet") .presentationDetents([.large, .medium]) .presentationDragIndicator(.hidden) } } .padding() } }
struct ContentView: View { @State private var presentSheet = false var body: some View { VStack { Text("DevTechie!") .font(.largeTitle) .foregroundColor(.primary) Button("Show Sheet") { presentSheet.toggle() } .buttonStyle(.borderedProminent) .sheet(isPresented: $presentSheet) { Text("This is a bottom sheet") .presentationDetents([ .fraction(0.25), .fraction(0.5), .fraction(0.75)]) } } .padding() } }
struct ContentView: View { @State private var presentSheet = false var body: some View { VStack { Text("DevTechie!") .font(.largeTitle) .foregroundColor(.primary) Button("Show Sheet") { presentSheet.toggle() } .buttonStyle(.borderedProminent) .sheet(isPresented: $presentSheet) { Text("This is a bottom sheet") .presentationDetents([ .height(100), .height(300), .height(500)]) } } .padding() } }
With that we have reached the end of this article. Thank you once again for reading. Subscribe to our weekly newsletter at https://www.devtechie.com