如何更改UIStoryboard中使用的动态颜色 [英] How to change dynamically color used in UIStoryboard
问题描述
我想知道是否可以在故事板中分配动态颜色。
I wonder if it's possible to assign a "dynamic" color in storyboard.
从iOS7开始,您可以使用tintColor并通过keyWindow的tintColor以编程方式更改它。但是我找不到一种方法来影响这个tintColor到一个按钮背景。这可以让我轻松地设置主题我的应用程序。
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.
我想通过在UIColor上使用类别并重载初始化程序以交换特定颜色来实现疯狂的黑客攻击当我需要动态颜色时使用这种颜色。
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".
任何想法?
推荐答案
我终于找到了解决方案..(必须等待工具存在:p)。
I finally found the solution.. (had to wait for the tool to exist :p).
蜡笔
是 Alcatraz
,允许您在Storyboard中重用一些代码定义颜色!是啊!
Crayons
is an Alcatraz
allowing you to re-use some code define color in Storyboard! yeah!
检查出来: https:// github。 com / Sephiroth87 / Crayons
这篇关于如何更改UIStoryboard中使用的动态颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!