<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAttributedString/size()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAttributedString(im)size"
  },
  "title" : "size()"
}
-->

# size()

Returns the size necessary to draw the string.

```
func size() -> CGSize
```

## Return Value

The minimum size required to draw the entire contents of the string.

## Discussion

You can use this method prior to drawing to compute how much space is required to draw the string.

This method may return fractional sizes. When setting the size of your view, use the <doc://com.apple.documentation/documentation/kernel/1557272-ceil> function to round fractional values up to the nearest whole number.

## See Also

[`-  drawAtPoint:`](/documentation/Foundation/NSAttributedString/draw(at:))

Draws the attributed string starting at the specified point in the current graphics context.

[`-  drawInRect:`](/documentation/Foundation/NSAttributedString/draw(in:))

Draws the attributed string inside the specified bounding rectangle in the current graphics context.



---

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)