Scales the view to fit its parent.
SDKs
- iOS 13.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- tvOS 13.0+
- Xcode 11.0+
Framework
- Swift
UI
Declaration
func scaledToFit() -> 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 aspect
.
Circle()
.fill(Color.pink)
.scaledToFit()
.frame(width: 300, height: 150)
.border(Color(white: 0.75))