---
title: "attachmentBounds(for:location:textContainer:proposedLineFragment:position:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextattachmentlayout/attachmentbounds(for:location:textcontainer:proposedlinefragment:position:)"
---

# attachmentBounds(for:location:textContainer:proposedLineFragment:position:)

Returns the layout bounds of the attachment you specify.

## Declaration

```swift
func attachmentBounds(for attributes: [NSAttributedString.Key : Any], location: any NSTextLocation, textContainer: NSTextContainer?, proposedLineFragment: CGRect, position: CGPoint) -> CGRect
```

## Parameters

- `attributes`: A dictionary of doc://com.apple.documentation/documentation/Foundation/NSAttributedString/Key attributes.
- `location`: An doc://com.apple.appkit/documentation/AppKit/NSTextLocation that indicates that start of the string.
- `textContainer`: The doc://com.apple.appkit/documentation/AppKit/NSTextContainer that contains the source text.
- `proposedLineFragment`: A doc://com.apple.documentation/documentation/CoreFoundation/CGRect that describes the boundaries of the line fragment.
- `position`: A doc://com.apple.documentation/documentation/CoreFoundation/CGPoint inside proposedLineFragment.

## Return Value

Return Value Returns a CGRect that describes the boundaries of the attachment, or CGRectZero.

## Discussion

Discussion The framework interprets the bounds origin to match position inside proposedLineFragment. The default NSTextAttachment implementation returns bounds if the value isn’t equivalent to CGRectZero; otherwise, it derives the bounds value from image.size. Conforming objects can implement more sophisticated logic for negotiating the frame size based on the available container space and proposed line fragment rectangle.

## See Also

### Determining the characteristics of an attachment

- [image(for:attributes:location:textContainer:)](appkit/nstextattachmentlayout/image(for:attributes:location:textcontainer:).md)
- [viewProvider(for:location:textContainer:)](appkit/nstextattachmentlayout/viewprovider(for:location:textcontainer:).md)
