<!--
{
  "availability" : [
    "macOS: 10.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAttributedString/boundingRect(with:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAttributedString(im)boundingRectWithSize:options:"
  },
  "title" : "boundingRect(with:options:)"
}
-->

# boundingRect(with:options:)

Calculates and returns a bounding rectangle for the attributed string using the options specified within the specified rectangle in the current graphics context.

```
func boundingRect(with size: NSSize, options: NSString.DrawingOptions = []) -> NSRect
```

## Parameters

`size`

The size of the rectangle to draw in.

`options`

The string drawing options. See <doc://com.apple.documentation/documentation/UIKit/NSStringDrawingOptions> for the possible values.

## Return Value

The bounding rectangle in the current graphics context.

## Discussion

The origin of the rectangle returned from this method is the first glyph origin.

---

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)