问题
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?
回答1:
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
回答2:
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.
Now, access it in storyboard in color palettes
Reference: https://blog.zeplin.io/asset-catalog-colors-on-xcode-9-c4fdccc0381a
来源:https://stackoverflow.com/questions/20061040/how-to-change-dynamically-color-used-in-uistoryboard