1

I wonder if it's possible to assign a "dynamic" color in storyboard.

Since iOS7 you can use a tintColor and change it programmatically via the tintColor of the keyWindow. But I can't find a way to affect this tintColor to a button background for example. Which could allow me to easily have a way to theme my application.

I thought of a crazy hack by using a category on UIColor and overloading the initializer to swap a specific color and use this color when ever I want a "dynamic color".

Any ideas?

Hugues BR
  • 2,238
  • 1
  • 20
  • 26

2 Answers2

3

I finally found the solution.. (had to wait for the tool to exist :p).

Crayons is an Alcatraz allowing you to re-use some code define color in Storyboard! yeah!

check it out: https://github.com/Sephiroth87/Crayons

Hugues BR
  • 2,238
  • 1
  • 20
  • 26
  • 3
    And now that plugins are forbidden in Xcode, have you got any other solution please ? :) EDIT : nevermind, just found that there is now an awesome way to deal with it (check this out https://blog.zeplin.io/asset-catalog-colors-on-xcode-9-c4fdccc0381a) – AnthoPak Jun 20 '18 at 14:40
  • Hum, turns out that it is only available for > iOS 11… – AnthoPak Jun 20 '18 at 14:54
1

Using asset catalog colors in Storyboards

Using asset catalog colors in a Storyboard or an Interface Builder file is pretty straightforward. All color fields, including view background colors, label text colors, should display the colors you defined in the asset catalog under the “Named Colors” section.

enter image description here

Now, access it in storyboard in color palettes

enter image description here

Reference: https://blog.zeplin.io/asset-catalog-colors-on-xcode-9-c4fdccc0381a

Naveed Ahmad
  • 6,627
  • 2
  • 58
  • 83