MarkosDarkin
MarkosDarkin

Reputation: 325

Colors and Themes in Xcode/Swift

This is more of a general question about working with Swift and Xcode but its really important for me to understand before i continue. My application use a specific set of colors for its components. example: Toolbars are black. Labels are white. Buttons are either green or blue. etc

  1. is there a good and efficient way to define 'Theme colors' somewhere in the code and use those variables instead of specifing a specific color for each component induvidualy? example: instead of going to a toolbar in storyboard and choosing the color 'black', i would use the code (or storyboard if possible) to set toolbar.color -> theme.toolbars.maincolor
  2. is it suggested to use work with Colors from code and not from storyboard? my co worker thinks its best to not use Colors at all in code and instead choose colors through storyboard only. i think its weird because then if i need to change a main color, for example, i would need to go through all storyboard items with that color and change them individualy.

Upvotes: 0

Views: 3049

Answers (1)

Konsy
Konsy

Reputation: 306

You would do it by using NSUserDefaults along with UIAppearance

There is a really good tutorial on how to do this by Ray Wenderlich which can be found here

Hope this helps!

Upvotes: 4

Related Questions