Contents

sizeThatFits(_:)

Asks the subview for its size.

Declaration

func sizeThatFits(_ proposal: ProposedViewSize) -> CGSize

Parameters

  • proposal:

    A proposed size for the subview. In SwiftUI, views choose their own size, but can take a size proposal from their parent view into account when doing so.

Return Value

The size that the subview chooses for itself, given the proposal from its container view.

Discussion

Use this method as a convenience to get the width and height properties of the ViewDimensions instance returned by the dimensions(in:) method, reported as a CGSize instance.

See Also

Getting subview characteristics