<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/aspectRatio3D(_:contentMode:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE13aspectRatio3D_11contentModeQrSo8SPSize3DaSg_AA07ContentG0OtF"
  },
  "title" : "aspectRatio3D(_:contentMode:)"
}
-->

# aspectRatio3D(_:contentMode:)

Constrains this view’s dimensions to the specified 3D aspect ratio.

```
@export(implementation) nonisolated func aspectRatio3D(_ aspectRatio: Size3D? = nil, contentMode: ContentMode) -> some View
```

## Parameters

`aspectRatio`

The ratio of width to height to depth to use for
the resulting view. If `aspectRatio` is `nil`,
the resulting view maintains this view’s aspect ratio.

`contentMode`

A flag indicating whether this view should fit or
fill the parent context.

## Return Value

A view that constrains this view’s dimensions to
`aspectRatio`, using `contentMode` as its scaling algorithm.

## Discussion

If this view is resizable, the resulting view will have `aspectRatio`
as its aspect ratio. In this example, the Model3D has a 2 : 3 : 1
width to height to depth ratio, and scales to fit its frame:

```
Model3D(named: "Sphere") { resolved in
    let ratio3D = Size3D(width: 2, height: 3, depth: 1)
    resolved
        .resizable()
        .aspectRatio3D(ratio3D, contentMode: .fit)
} placeholder: {
    ProgressView()
}
.frame(width: 200, height: 200)
.frame(depth: 200)
.border(Color(white: 0.75))
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)