<!--
{
  "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/CGRectIntersection(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@F@CGRectIntersection"
  },
  "title" : "CGRectIntersection(_:_:)"
}
-->

# CGRectIntersection(_:_:)

Returns the intersection of two rectangles.

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

## Parameters

`r1`

The first source rectangle.

`r2`

The second source rectangle.

## 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(_:)`](/documentation/CoreGraphics/CGRectIsNull(_:)).

## Discussion

Both rectangles are standardized prior to calculating the intersection.

---

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)