<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Shape/size(width:height:anchor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI5ShapePAAE4size5width6height6anchorQr14CoreFoundation7CGFloatV_AjA9UnitPointVtF"
  },
  "title" : "size(width:height:anchor:)"
}
-->

# size(width:height:anchor:)

Returns a new version of self representing the same shape, but
within a rect of `(width, height)` instead of the container size.

```
nonisolated func size(width: CGFloat, height: CGFloat, anchor: UnitPoint) -> some Shape
```

## Parameters

`width`

The width to constrain the shape to.

`height`

The height to constrain the shape to.

`anchor`

The anchor to use to determine how to position the new
shape.

## Return Value

A new shape constrained to the given `size`, and positioned
using `anchor`.

## Discussion

The `anchor` parameter determines how the shape will be positioned
within the container when the path’s bounds and the container’s bounds
are not equal. This does not affect the layout properties of any views
created from the shape (e.g. by filling it).

---

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)