---
title: "CGRectIntersection(_:_:)"
framework: coregraphics
role: symbol
role_heading: Function
path: "coregraphics/cgrectintersection(_:_:)"
---

# CGRectIntersection(_:_:)

Returns the intersection of two rectangles.

## Declaration

```swift
func CGRectIntersection(_ r1: CGRect, _ r2: CGRect) -> CGRect
```

## Parameters

- `r1`: The first source rectangle.
- `r2`: The second source rectangle.

## Return Value

Return Value A rectangle that represents the intersection of the two specified rectangles. If the two rectangles do not intersect, returns the null rectangle. To check for this condition, use CGRectIsNull(_:).

## Discussion

Discussion Both rectangles are standardized prior to calculating the intersection.

## See Also

### Modifying Rectangles

- [CGRectInset(_:_:_:)](coregraphics/cgrectinset(_:_:_:).md)
- [CGRectIntegral(_:)](coregraphics/cgrectintegral(_:).md)
- [CGRectOffset(_:_:_:)](coregraphics/cgrectoffset(_:_:_:).md)
- [CGRectStandardize(_:)](coregraphics/cgrectstandardize(_:).md)
- [CGRectUnion(_:_:)](coregraphics/cgrectunion(_:_:).md)
