<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextView/changeDocumentBackgroundColor(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextView(im)changeDocumentBackgroundColor:"
  },
  "title" : "changeDocumentBackgroundColor(_:)"
}
-->

# changeDocumentBackgroundColor(_:)

An action method used to set the background color.

```
func changeDocumentBackgroundColor(_ sender: Any?)
```

## Parameters

`sender`

The control that wants to set the background color.

## Discussion

This method gets the new color by sending a [`color`](/documentation/AppKit/NSColorPanel/color) message to  `sender`.

This will only set the background color if [`allowsDocumentBackgroundColorChange`](/documentation/AppKit/NSTextView/allowsDocumentBackgroundColorChange)returns <doc://com.apple.documentation/documentation/Swift/true>.

---

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)