title: Xcode - Cannot set UITextView background color (device in dark mode)
body: <p>I am trying to force a UITextView to keep the background color of white regardless of the mode set on the device. At the moment, when the device is set in light mode, the background of the UITextView is white, if the user changes to dark mode, the UITextView changes to black (probably the expected behaviour).</p>
  <p>I want to force the background color for UITextView to white regardless of the mode set on the device.</p>
  <p>I have tried changing this everywhere both in the UI of Xcode and in the code, but it does not seem to respect the color set and always changes the background colour to black.</p>
  <p>Here is the source code:</p>
  <pre><code>&lt;view clipsSubviews=&quot;YES&quot; contentMode=&quot;scaleToFill&quot; translatesAutoresizingMaskIntoConstraints=&quot;NO&quot; id=&quot;yI7-hV-e1x&quot;&gt;
                                                  &lt;rect key=&quot;frame&quot; x=&quot;20&quot; y=&quot;139&quot; width=&quot;335&quot; height=&quot;150&quot;/&gt;
                                                  &lt;subviews&gt;
                                                      &lt;textView clipsSubviews=&quot;YES&quot; multipleTouchEnabled=&quot;YES&quot; contentMode=&quot;scaleToFill&quot; textAlignment=&quot;natural&quot; translatesAutoresizingMaskIntoConstraints=&quot;NO&quot; id=&quot;zzp-UV-fkE&quot;&gt;
                                                          &lt;rect key=&quot;frame&quot; x=&quot;0.0&quot; y=&quot;0.0&quot; width=&quot;335&quot; height=&quot;150&quot;/&gt;
                                                          &lt;color key=&quot;backgroundColor&quot; white=&quot;1&quot; alpha=&quot;1&quot; colorSpace=&quot;calibratedWhite&quot;/&gt;
                                                          &lt;fontDescription key=&quot;fontDescription&quot; type=&quot;system&quot; pointSize=&quot;17&quot;/&gt;
                                                          &lt;textInputTraits key=&quot;textInputTraits&quot; autocapitalizationType=&quot;sentences&quot;/&gt;
                                                          &lt;userDefinedRuntimeAttributes&gt;
                                                              &lt;userDefinedRuntimeAttribute type=&quot;string&quot; keyPath=&quot;placeholder&quot; value=&quot;Enter message here&quot;/&gt;
                                                              &lt;userDefinedRuntimeAttribute type=&quot;color&quot; keyPath=&quot;background.Color&quot;&gt;
                                                                  &lt;color key=&quot;value&quot; white=&quot;1&quot; alpha=&quot;1&quot; colorSpace=&quot;custom&quot; customColorSpace=&quot;genericGamma22GrayColorSpace&quot;/&gt;
                                                              &lt;/userDefinedRuntimeAttribute&gt;
                                                              &lt;userDefinedRuntimeAttribute type=&quot;color&quot; keyPath=&quot;color&quot;&gt;
                                                                  &lt;color key=&quot;value&quot; white=&quot;1&quot; alpha=&quot;1&quot; colorSpace=&quot;custom&quot; customColorSpace=&quot;genericGamma22GrayColorSpace&quot;/&gt;
                                                              &lt;/userDefinedRuntimeAttribute&gt;
                                                              &lt;userDefinedRuntimeAttribute type=&quot;color&quot; keyPath=&quot;UITextView.backgroundColor&quot;&gt;
                                                                  &lt;color key=&quot;value&quot; white=&quot;1&quot; alpha=&quot;1&quot; colorSpace=&quot;custom&quot; customColorSpace=&quot;genericGamma22GrayColorSpace&quot;/&gt;
                                                              &lt;/userDefinedRuntimeAttribute&gt;
                                                          &lt;/userDefinedRuntimeAttributes&gt;
                                                      &lt;/textView&gt;
                                                  &lt;/subviews&gt;
                                                  &lt;color key=&quot;backgroundColor&quot; white=&quot;1&quot; alpha=&quot;1&quot; colorSpace=&quot;custom&quot; customColorSpace=&quot;genericGamma22GrayColorSpace&quot;/&gt;
                                                  &lt;constraints&gt;
                                                      &lt;constraint firstAttribute=&quot;trailing&quot; secondItem=&quot;zzp-UV-fkE&quot; secondAttribute=&quot;trailing&quot; id=&quot;3r4-ih-LvH&quot;/&gt;
                                                      &lt;constraint firstAttribute=&quot;bottom&quot; secondItem=&quot;zzp-UV-fkE&quot; secondAttribute=&quot;bottom&quot; id=&quot;43N-Io-MuA&quot;/&gt;
                                                      &lt;constraint firstItem=&quot;zzp-UV-fkE&quot; firstAttribute=&quot;leading&quot; secondItem=&quot;yI7-hV-e1x&quot; secondAttribute=&quot;leading&quot; id=&quot;FUG-Np-Cu1&quot;/&gt;
                                                      &lt;constraint firstItem=&quot;zzp-UV-fkE&quot; firstAttribute=&quot;top&quot; secondItem=&quot;yI7-hV-e1x&quot; secondAttribute=&quot;top&quot; id=&quot;r6c-Py-iV8&quot;/&gt;
                                                      &lt;constraint firstAttribute=&quot;height&quot; constant=&quot;150&quot; id=&quot;xlc-gd-Q43&quot;/&gt;
                                                  &lt;/constraints&gt;
                                                  &lt;userDefinedRuntimeAttributes&gt;
                                                      &lt;userDefinedRuntimeAttribute type=&quot;number&quot; keyPath=&quot;layer.cornerRadius&quot;&gt;
                                                          &lt;integer key=&quot;value&quot; value=&quot;7&quot;/&gt;
                                                      &lt;/userDefinedRuntimeAttribute&gt;
                                                      &lt;userDefinedRuntimeAttribute type=&quot;number&quot; keyPath=&quot;layer.borderWidth&quot;&gt;
                                                          &lt;integer key=&quot;value&quot; value=&quot;1&quot;/&gt;
                                                      &lt;/userDefinedRuntimeAttribute&gt;
                                                      &lt;userDefinedRuntimeAttribute type=&quot;color&quot; keyPath=&quot;layer.borderColor&quot;&gt;
                                                          &lt;color key=&quot;value&quot; white=&quot;1&quot; alpha=&quot;1&quot; colorSpace=&quot;custom&quot; customColorSpace=&quot;genericGamma22GrayColorSpace&quot;/&gt;
                                                      &lt;/userDefinedRuntimeAttribute&gt;
                                                      &lt;userDefinedRuntimeAttribute type=&quot;color&quot; keyPath=&quot;background.Color&quot;&gt;
                                                          &lt;color key=&quot;value&quot; white=&quot;1&quot; alpha=&quot;1&quot; colorSpace=&quot;custom&quot; customColorSpace=&quot;genericGamma22GrayColorSpace&quot;/&gt;
                                                      &lt;/userDefinedRuntimeAttribute&gt;
                                                  &lt;/userDefinedRuntimeAttributes&gt;
                                              &lt;/view&gt;
  </code></pre>
  <p>This is what it looks like in dark mode:</p>
  <p><a href="https://i.stack.imgur.com/bX9uU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bX9uU.png" alt="enter image description here" /></a></p>
  <p>And this is Light Mode:</p>
  <p><a href="https://i.stack.imgur.com/9I8ay.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9I8ay.png" alt="enter image description here" /></a></p>
  <p>I want the background permanently set to white.</p>