<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutManager/drawBackground(forGlyphRange:at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutManager(im)drawBackgroundForGlyphRange:atPoint:"
  },
  "title" : "drawBackground(forGlyphRange:at:)"
}
-->

# drawBackground(forGlyphRange:at:)

Draws background marks for the specified glyphs, which must lie completely within a single text container.

```
func drawBackground(forGlyphRange glyphsToShow: NSRange, at origin: NSPoint)
```

## Parameters

`glyphsToShow`

The range of glyphs for which the background is drawn.

`origin`

The position of the text container in the coordinate system of the currently focused view.

## Discussion

This method is called by `NSTextView` for drawing. You can override it to perform additional drawing, or to replace text drawing entirely, but not to change layout. You can call this method directly, but focus must already be locked on the destination view or image.

Background marks are such things as selection highlighting, text background color, and any background for marked text, along with block decoration such as table backgrounds and borders.

Performs glyph generation and layout if needed.

---

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)