---
title: "drawBackground(withFrame:in:characterRange:layoutManager:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextblock/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.

## Declaration

```swift
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 doc://com.apple.appkit/documentation/AppKit/NSTextStorage object whose glyphs are to be drawn.
- `layoutManager`: The layout manager controlling the typesetting.
