PresentationSizing
A type that defines the size of the presentation content and how the presentation size adjusts to its content’s size changing.
Declaration
protocol PresentationSizingOverview
You don’t need to define your own version of this protocol. The system implementations of form, page, and 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 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))