Declaration
compose().scaledToFill()nonisolated func scaledToFill() -> some ViewReturn value
A view that scales this view to fill its parent, maintaining this view's aspect ratio.
Discussion
Use scaledToFill() to scale this view to fill its parent, while
maintaining the view's aspect ratio as the view scales:
Circle()
.fill(Color.pink)
.scaledToFill()
.frame(width: 300, height: 150)
.border(Color(white: 0.75))This method is equivalent to calling
View.aspectRatio(_:contentMode:) with a nil aspectRatio and
a content mode of ContentMode.fill.
See also
More in Appearance.
- backgroundSets the view's background to a style.
- badgeGenerates a badge for the view from a localized string resource.
- badgeProminenceSpecifies the prominence of badges created by this view.
- borderAdds a border to this view with the specified style and width.
- buttonSizingThe preferred sizing behavior of buttons in the view hierarchy.
- containerBackgroundSets the container background of the enclosing container using a view.
- headerProminenceSets the header prominence for this view.
- hiddenHides this view unconditionally.
- imageScaleScales images within the view according to one of the relative sizes available including small, medium, and large images sizes.
- labelIconToTitleSpacingSet the spacing between the icon and title in labels.
- labelReservedIconWidthSet the width reserved for icons in labels.
- labelsHiddenHides the labels of any controls contained within this view.