One Logo Pool Ball
SwiftUI · IOS API REFERENCE

CustomPresentationDetent

protocol · iOS 16.0+ · SDK 27.1

protocol CustomPresentationDetent

The definition of a custom detent with a calculated height. You can create and use a custom detent with built-in detents. extension PresentationDetent { static let bar = Self.custom(BarDetent.self) static let small = Self.height(100) static let extraLarge = Self.fraction(0.75) } private struct BarDetent: CustomPresentationDetent { static func height(in context: Context) -> CGFloat? { max(44, context.maxDetentValue * 0.1) } } struct ContentView: View { @State private var showSettings = false @State private var selectedDetent = PresentationDetent.bar var body: some View { Button("View Settings") { showSettings = true } .sheet(isPresented: $showSettings) { SettingsView(selectedDetent: $selectedDetent) .presentationDetents( [.bar, .small, .medium, .large, .extraLarge], selection: $selectedDetent) } } }

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUI types →