<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Path/addRect(_:transform:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4PathV7addRect_9transformySo6CGRectV_So17CGAffineTransformVtF"
  },
  "title" : "addRect(_:transform:)"
}
-->

# addRect(_:transform:)

Adds a rectangular subpath to the path.

```
mutating func addRect(_ rect: CGRect, transform: CGAffineTransform = .identity)
```

## Parameters

`rect`

A rectangle, specified in user space coordinates.

`transform`

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

## Discussion

This is a convenience function that adds a rectangle to a path,
starting by moving to the bottom-left corner and then adding
lines counter-clockwise to create a rectangle, closing the
subpath.

---

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)