<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKShapeNode/init(rectOf:cornerRadius:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SKShapeNode(cm)shapeNodeWithRectOfSize:cornerRadius:"
  },
  "title" : "init(rectOf:cornerRadius:)"
}
-->

# init(rectOf:cornerRadius:)

Creates a shape with a rectangular path that has rounded corners centered on the node’s position.

```
convenience init(rectOf size: CGSize, cornerRadius: CGFloat)
```

## Parameters

`size`

The size of the rectangle.

`cornerRadius`

The radius of the rounded corners. The radius should not be a negative number. The value should be no larger than half of the rectangle’s width or height, whichever is smaller.

## Return Value

A new shape node.

## Discussion

---

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)