---
title: "addRoundedRect(in:cornerSize:style:transform:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/path/addroundedrect(in:cornersize:style:transform:)"
---

# addRoundedRect(in:cornerSize:style:transform:)

Adds a rounded rectangle to the path.

## Declaration

```swift
mutating func addRoundedRect(in rect: CGRect, cornerSize: CGSize, style: RoundedCornerStyle = .continuous, transform: CGAffineTransform = .identity)
```

## Parameters

- `rect`: A rectangle, specified in user space coordinates.
- `cornerSize`: The size of the corners, specified in user space coordinates.
- `style`: The corner style. Defaults to the continous style if not specified.
- `transform`: An affine transform to apply to the rectangle before adding to the path. Defaults to the identity transform if not specified.

## Discussion

Discussion This is a convenience function that adds a rounded rectangle to a path, starting by moving to the center of the right edge and then adding lines and curves counter-clockwise to create a rounded rectangle, closing the subpath.

## See Also

### Drawing a path

- [move(to:)](swiftui/path/move(to:).md)
- [addArc(center:radius:startAngle:endAngle:clockwise:transform:)](swiftui/path/addarc(center:radius:startangle:endangle:clockwise:transform:).md)
- [addArc(tangent1End:tangent2End:radius:transform:)](swiftui/path/addarc(tangent1end:tangent2end:radius:transform:).md)
- [addCurve(to:control1:control2:)](swiftui/path/addcurve(to:control1:control2:).md)
- [addEllipse(in:transform:)](swiftui/path/addellipse(in:transform:).md)
- [addLine(to:)](swiftui/path/addline(to:).md)
- [addLines(_:)](swiftui/path/addlines(_:).md)
- [addPath(_:transform:)](swiftui/path/addpath(_:transform:).md)
- [addQuadCurve(to:control:)](swiftui/path/addquadcurve(to:control:).md)
- [addRect(_:transform:)](swiftui/path/addrect(_:transform:).md)
- [addRects(_:transform:)](swiftui/path/addrects(_:transform:).md)
- [addRelativeArc(center:radius:startAngle:delta:transform:)](swiftui/path/addrelativearc(center:radius:startangle:delta:transform:).md)
- [closeSubpath()](swiftui/path/closesubpath().md)
