One Logo Pool Ball
SwiftUI · IOS API REFERENCE

PresentationSizing

protocol · iOS 18.0+ · SDK 27.1

protocol PresentationSizing

A type that defines the size of the presentation content and how the presentation size adjusts to its content's size changing. You don't need to define your own version of this protocol. The system implementations of ``PresentationSizing/form``, ``PresentationSizing/page``, and ``PresentationSizing/fitted`` are conveniences that automatically adapt to different device and screen sizes. If you do want to define your own sizing, first consider using the modifiers ``PresenationSizing/sticky(horizontal:vertical:)`` and ``PresentationSizing/fitted(horizontal:vertical:)``. For example, to define your own sizing that proposes a 400x400 square size: protocol SquareSizing: PresentationSizing { func proposedSize( for subview: PresentationSizingRoot, context: PresentationSizingContext ) { .init(width: 400, height: 400) } } extension PresentationSizing where Self == SquareSizing { public static var square: Self { SquareSizing() } } Then, at the callsite, you can modify `.square` just like system sizings, for example, to fit its content vertically: .presentationSizing(.square.fitted(horizontal: false, vertical: true)) - Seealso: ``View/presentationSizing(_:)``

Members (2)

method · iOS 18.0+

fitted

Swift declaration
func fitted(horizontal: Bool, vertical: Bool) -> some PresentationSizing
method · iOS 18.0+

sticky

Swift declaration
func sticky(horizontal: Bool = false, vertical: Bool = false) -> some PresentationSizing

Modifies self to be sticky in the specified dimensions — growing, but not shrinking. If `sticky` is `.vertical`, the presentation can grow in the vertical and horizontal dimensions when its content size grows, but will not shrink in the vertical dimension when content size shrinks. ContentView() .sheet(isPresented: $presentSheet) { MyDynamicSheetContent() .presentationSizing( .form.sticky(horizontal: false, vertical: true)) } - Seealso: ``PresentationSizing/fitted(horizontal:vertical:)`` - Parameters: - horizontal: A boolean indicating whether to maintain the largest size horizontally - vertical: A boolean indicating whether to maintain the largest size vertically - Returns: a modified version of self sticking to dimensions specified

Skipped declarations

4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

PresentationSizing.form

Static protocol requirements cannot be called through an instance.

PresentationSizing.page

Static protocol requirements cannot be called through an instance.

PresentationSizing.fitted

Static protocol requirements cannot be called through an instance.

PresentationSizing.automatic

Static protocol requirements cannot be called through an instance.

All SwiftUI types →