---
title: "boundingRect(with:options:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsattributedstring/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.

## Declaration

```swift
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

Return Value The bounding rectangle in the current graphics context.

## Discussion

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

## See Also

### Deprecated Instance Methods

- [url(at:effectiveRange:)](foundation/nsattributedstring/url(at:effectiverange:).md)
- [draw(with:options:)](foundation/nsattributedstring/draw(with:options:).md)
