ios - 使用动态颜色创建 UI 的最佳方法

标签 ios cocoa cocoa-touch user-interface

我正在构建一个 iOS 应用程序,允许用户选择配色方案。该应用程序基本上有一种我想更改的强调色,但它在整个应用程序中的标签、背景、按钮、表格中的内容等上使用...

解决冗长代码的最佳方法是什么?

我的第一个选择是在每个 UI 元素中手动编写代码(很长的路要走)。他们是更简单的方法吗?

我看到了这个问题,但答案似乎不适用于我的情况:Can I tag a UIColor?

最佳答案

听起来你想看看UIAppearance :

You can customize the appearance of instances of a class by sending appearance modification messages to the class’s appearance proxy.

For example, to modify the bar background tint color for all instances of UINavigationBar:

[[UINavigationBar appearance] setBarTintColor:myNavBarBackgroundColor];

一些评论here

关于ios - 使用动态颜色创建 UI 的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27736144/

相关文章:

ios - NSInternalInconsistencyException 错误

ios - pathForResource 为 plist 返回 null

ios - Swift - 在类中定义属性

iphone - 将 iPhone 挂载为磁盘

ios - UIPanGestureRecognizer 将事件传递给下面的按钮

iphone - 高效地访问数组内的数组

iOS 应用被苹果应用商店拒绝,因为 UIWebview

ios - Swift CIfilter 从 collectionView 中选择

objective-c - 如何使用 ObjectMapper 映射 json 响应?

objective-c - 如何让NSView的背景图片不重复?