<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextAttachmentViewProvider/attachmentBounds(for:location:textContainer:proposedLineFragment:position:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextAttachmentViewProvider(im)attachmentBoundsForAttributes:location:textContainer:proposedLineFragment:position:"
  },
  "title" : "attachmentBounds(for:location:textContainer:proposedLineFragment:position:)"
}
-->

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

Returns the layout bounds for an attachment at a specific text location that contains the text attributes you specify.

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

## Parameters

`attributes`

A dictionary that contains a list of key and attribute pairs that describe the customization of the string.

`location`

An [`NSTextLocation`](/documentation/AppKit/NSTextLocation) that indicates that start of the string.

`textContainer`

The [`NSTextContainer`](/documentation/AppKit/NSTextContainer) that contains the source string.

`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

Returns a <doc://com.apple.documentation/documentation/CoreFoundation/CGRect> that describes the bounds of the attachment.

---

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)