---
title: "frameForTextAttachment(at:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextlayoutfragment/framefortextattachment(at:)"
---

# frameForTextAttachment(at:)

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

## Declaration

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

## Parameters

- `location`: The doc://com.apple.appkit/documentation/AppKit/NSTextLocation that describes the location in the text layout fragment.

## Return Value

Return Value The frame rectangle that describes the text layout fragment.

## Discussion

Discussion Returns CGRectZero if location isn’t with any attachment or the state isn’t NSTextLayoutFragment.State.layoutAvailable.

## See Also

### Drawing the fragment and attachments

- [layoutFragmentFrame](appkit/nstextlayoutfragment/layoutfragmentframe.md)
- [renderingSurfaceBounds](appkit/nstextlayoutfragment/renderingsurfacebounds.md)
- [draw(at:in:)](appkit/nstextlayoutfragment/draw(at:in:).md)
- [invalidateLayout()](appkit/nstextlayoutfragment/invalidatelayout().md)
- [textAttachmentViewProviders](appkit/nstextlayoutfragment/textattachmentviewproviders.md)
