---
title: "CGRectContainsRect(_:_:)"
framework: coregraphics
role: symbol
role_heading: Function
path: "coregraphics/cgrectcontainsrect(_:_:)"
---

# CGRectContainsRect(_:_:)

Returns whether the first rectangle contains the second rectangle.

## Declaration

```swift
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

Return Value true if the rectangle specified by rect2 is contained in the rectangle passed in rect1; otherwise, false. The first rectangle contains the second if the union of the two rectangles is equal to the first rectangle.

## See Also

### Checking for Membership

- [CGRectContainsPoint(_:_:)](coregraphics/cgrectcontainspoint(_:_:).md)
