Instance Method

scaledToFill()

Scales the view to fill its parent.

Declaration

func scaledToFill() -> some View

Return Value

A view that scales this view to fit its parent, maintaining this view’s aspect ratio.

Discussion

This view’s aspect ratio is maintained as the view scales. This method is equivalent to calling aspectRatio(nil, contentMode: .fill).

Circle()
.fill(Color.pink)
.scaledToFill()
.frame(width: 300, height: 150)
.border(Color(white: 0.75))