0

I am making a dark mode setting for my app.

Currently, the dark mode is nearly working on a single scene. While adding the dark mode though, I noticed that I need a lot of IBOutletCollection to properly change the colors that I want (ex. labels should become white, background black, the title should be a very dark gray...).

Now, this seems inefficient and time consuming. Isn't there a way to load everything, for() it, and set the correct color for each specific object? (If there is, how?)

rmaddy
  • 314,917
  • 42
  • 532
  • 579
G. Ramistella
  • 1,327
  • 1
  • 9
  • 19

1 Answers1

0

UIAppearance is what you are looking for, it’s meant to be used for changing the appearance of a class https://developer.apple.com/documentation/uikit/uiappearance?language=objc

For example a label would be styled like this:

[[UILabel appearance] setTextColor: [UIColor whiteColor]];

See also related question on how to do the actual switching of the themes Using UIAppearance and switching themes

Skyria
  • 71
  • 1
  • 5