<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextLayoutFragment/frameForTextAttachment(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextLayoutFragment(im)frameForTextAttachmentAtLocation:"
  },
  "title" : "frameForTextAttachment(at:)"
}
-->

# frameForTextAttachment(at:)

Returns the frame in the text layout fragment coordinate system for the attachment at the location you specify.

```
func frameForTextAttachment(at location: any NSTextLocation) -> CGRect
```

## Parameters

`location`

The [`NSTextLocation`](/documentation/AppKit/NSTextLocation) that describes the location in the text layout fragment.

## Return Value

The frame rectangle that describes the text layout fragment.

## Discussion

Returns <doc://com.apple.documentation/documentation/CoreGraphics/CGRectZero> if `location` isn’t with any attachment or the state isn’t [`NSTextLayoutFragment.State.layoutAvailable`](/documentation/AppKit/NSTextLayoutFragment/State-swift.enum/layoutAvailable).

---

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)