<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGRectContainsRect(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@F@CGRectContainsRect"
  },
  "title" : "CGRectContainsRect(_:_:)"
}
-->

# CGRectContainsRect(_:_:)

Returns whether the first rectangle contains the second rectangle.

```
func CGRectContainsRect(_ rect1: CGRect, _ rect2: CGRect) -> Bool
```

## Parameters

`rect1`

The rectangle to examine for containment of the rectangle passed in `rect2`.

`rect2`

The rectangle to examine for being contained in the rectangle passed in `rect1`.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the rectangle specified by `rect2` is contained in the rectangle passed in `rect1`; otherwise, <doc://com.apple.documentation/documentation/Swift/false>. The first rectangle contains the second if the union of the two rectangles is equal to the first rectangle.

## Discussion

---

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)