scaledToFill()
Scales this view to fill its parent.
Declaration
nonisolated func scaledToFill() -> some View
Return 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))[Image]
This method is equivalent to calling aspectRatio(_:contentMode:) with a nil aspectRatio and a content mode of ContentMode.fill.
See Also
Scaling, rotating, or transforming a view
scaledToFit()scaleEffect(_:anchor:)scaleEffect(_:anchor:)scaleEffect(x:y:anchor:)scaleEffect(x:y:z:anchor:)aspectRatio(_:contentMode:)rotationEffect(_:anchor:)rotation3DEffect(_:axis:anchor:anchorZ:perspective:)perspectiveRotationEffect(_:axis:anchor:anchorZ:perspective:)rotation3DEffect(_:anchor:)rotation3DEffect(_:axis:anchor:)transformEffect(_:)transform3DEffect(_:)projectionEffect(_:)ProjectionTransform