<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSLayoutManager/setAttachmentSize(_:forGlyphRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutManager(im)setAttachmentSize:forGlyphRange:"
  },
  "title" : "setAttachmentSize(_:forGlyphRange:)"
}
-->

# setAttachmentSize(_:forGlyphRange:)

Sets the size to use when drawing a glyph that represents an attachment.

```
func setAttachmentSize(_ attachmentSize: CGSize, forGlyphRange glyphRange: NSRange)
```

## Parameters

`attachmentSize`

The glyph size to set.

`glyphRange`

The attachment glyph’s position in the glyph stream.

## Discussion

For a glyph corresponding to an attachment, this method should be called to set the size for the attachment cell to occupy. The glyph’s value should be <doc://com.apple.documentation/documentation/AppKit/NSControlGlyph>.

This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

## See Also

[`func attachmentSize(forGlyphAt: Int) -> CGSize`](/documentation/UIKit/NSLayoutManager/attachmentSize(forGlyphAt:))

Returns the size of the attachment glyph at the specified index.

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/defaultAttachmentScaling>



---

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)