3

I am trying to change the text color in a UITextView from light grey to white/black.

So the new text color should be white when the dark mode is on and the text color should be black when the light mode is on.

Fabian Müller
  • 318
  • 2
  • 11

1 Answers1

9

You can set the UIColor to .label

textView.textColor = .label

This should use the system label colour which is back against a white background and vice versa

You can also create your own dark/light colours in the assets file. enter image description here

And then use them in code or the interface builder.

textView.textColor = UIColor.init(named: "myBlueColor")
J_B_UK
  • 347
  • 5
  • 12