<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextBlock/drawBackground(withFrame:in:characterRange:layoutManager:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextBlock(im)drawBackgroundWithFrame:inView:characterRange:layoutManager:"
  },
  "title" : "drawBackground(withFrame:in:characterRange:layoutManager:)"
}
-->

# drawBackground(withFrame:in:characterRange:layoutManager:)

Called by the layout manager to draw any colors and other decorations before the text is drawn.

```
func drawBackground(withFrame frameRect: NSRect, in controlView: NSView?, characterRange charRange: NSRange, layoutManager: NSLayoutManager)
```

## Parameters

`frameRect`

The bounds rectangle in view coordinates.

`controlView`

The view in which drawing occurs.

`charRange`

The range of the characters in the [`NSTextStorage`](/documentation/AppKit/NSTextStorage) object whose glyphs are to be drawn.

`layoutManager`

The layout manager controlling the typesetting.

---

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)