---
title: "setBackgroundColor(_:in:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avmutablecaption/setbackgroundcolor(_:in:)"
---

# setBackgroundColor(_:in:)

Sets the background color for a range of text.

## Declaration

```swift
@nonobjc func setBackgroundColor(_ backgroundColor: CGColor, in range: NSRange)
```

## Parameters

- `backgroundColor`: The background color.
- `range`: The range to which this background color applies.

## See Also

### Configuring colors

- [setTextColor(_:in:)](avfoundation/avmutablecaption/settextcolor(_:in:).md)
- [removeTextColor(in:)](avfoundation/avmutablecaption/removetextcolor(in:).md)
- [removeBackgroundColor(in:)](avfoundation/avmutablecaption/removebackgroundcolor(in:).md)
