PresentationSizing
A type that defines the size of the presentation content and how the presentation size adjusts to its content's size changing.
Declaration
type PresentationSizing =
| 'automatic'
| 'fitted'
| 'form'
| 'page'
| PresentationSizingChain;protocol PresentationSizingPass a literal, or build one with SwiftUI.PresentationSizing from import { SwiftUI } from 'swiftui-react-native'.
Type properties
'automatic'SwiftUI.PresentationSizing.automaticThe default presentation sizing, appropriate for the platform.
'fitted'SwiftUI.PresentationSizing.fittedThe presentation sizing is dictated by the ideal size of the content
'form'SwiftUI.PresentationSizing.formThe size is appropriate for forms and slightly less wide than
.page'page'SwiftUI.PresentationSizing.pageThe size is roughly the size of a page of paper, appropriate for informational or compositional content.
Overview
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(_:)
From Apple’s SwiftUI documentation. Code samples there are Swift.
Used by
See also
More in Presentation.
- AutomaticPresentationSizingThe default presentation sizing, appropriate for the platform.
- DismissActionAn action that dismisses a presentation.
- DismissBehaviorProgrammatic window dismissal behaviors.
- DismissWindowActionAn action that dismisses a window associated to a particular scene.
- FileDialogBrowserOptionsThe way that file dialogs present the file system.
- FittedPresentationSizingThe size of the presentation is dictated by the ideal size of the content.
- FormPresentationSizingThe size is appropriate for forms and slightly less wide than.page
- MenuActionDismissBehaviorThe set of menu dismissal behavior options.
- MenuOrderThe order in which a menu presents its content.
- PagePresentationSizingThe size is roughly the size of a page of paper, appropriate for informational or compositional content.
- PopoverAttachmentAnchorAn attachment anchor for a popover.
- PresentationAdaptationStrategies for adapting a presentation to a different size class.