<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVMakeRect(aspectRatio:insideRect:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:@F@AVMakeRectWithAspectRatioInsideRect"
  },
  "title" : "AVMakeRect(aspectRatio:insideRect:)"
}
-->

# AVMakeRect(aspectRatio:insideRect:)

Returns a scaled rectangle that maintains the specified aspect ratio within a bounding rectangle.

```
func AVMakeRect(aspectRatio: CGSize, insideRect boundingRect: CGRect) -> CGRect
```

## Parameters

`aspectRatio`

The width and height ratio (aspect ratio) you want to maintain.

`boundingRect`

The bounding rectangle you want to fit into.

## Return Value

Returns a scaled `CGRect` that maintains the aspect ratio specified by `aspectRatio` that fits within `boundingRect`.

## Discussion

Use this function when attempting to fit the presentation size of a player item object’s content within the bounds of another <doc://com.apple.documentation/documentation/QuartzCore/CALayer>. Use the returned <doc://com.apple.documentation/documentation/CoreFoundation/CGRect> as the player layer’s <doc://com.apple.documentation/documentation/QuartzCore/CALayer/frame> property value. For example:

```swift
let aspectRatio = CGSize(width: 1920, height: 1080)
playerLayer.frame = AVMakeRect(aspectRatio: aspectRatio, insideRect: superLayer.bounds)
```

---

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)