---
title: "frameForTextAttachment(at:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/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.uikit/documentation/UIKit/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](uikit/nstextlayoutfragment/layoutfragmentframe.md)
- [renderingSurfaceBounds](uikit/nstextlayoutfragment/renderingsurfacebounds.md)
- [draw(at:in:)](uikit/nstextlayoutfragment/draw(at:in:).md)
- [invalidateLayout()](uikit/nstextlayoutfragment/invalidatelayout().md)
- [textAttachmentViewProviders](uikit/nstextlayoutfragment/textattachmentviewproviders.md)
