<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGMutablePath/addRects(_:transform:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "s:So16CGMutablePathRefa12CoreGraphicsE8addRects_9transformySaySo6CGRectVG_So17CGAffineTransformVtF"
  },
  "title" : "addRects(_:transform:)"
}
-->

# addRects(_:transform:)

Adds a set of rectangular subpaths to the path.

```
func addRects(_ rects: [CGRect], transform: CGAffineTransform = .identity)
```

## Parameters

`rects`

An array of rectangles, specified in user space coordinates.

`transform`

An affine transform to apply to the rectangles before adding to the path. Defaults to the identity transform if not specified.

## Discussion

Calling this convenience method is equivalent to repeatedly calling the [`addRect(_:transform:)`](/documentation/CoreGraphics/CGMutablePath/addRect(_:transform:)) method for each rectangle in the array.

---

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)