使用 Swift 在整个应用程序中更改 UILabel 的 textColor [英] Change UILabel's textColor in whole app using Swift

查看:28
本文介绍了使用 Swift 在整个应用程序中更改 UILabel 的 textColor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Swift 中有什么方法可以在整个应用程序中一次性更改 UILabel 的文本颜色属性吗?我试过使用外观属性,但这不适用于 UILabel textColor.任何方式或任何可以使用相同方法的库.

Is there any way in Swift i can change my UILabel's text color property at once in whole app? I've tried using appeareance property but that doesn't work for UILabel textColor. Any way or any library that works on the same.

推荐答案

一种方法是使用 Color Set.

首先在您的 xcassets 目录中创建新集

Start with creating new set in your xcassets catalog

...并按照您想要的方式命名

... and name it how you want to

然后将颜色更改为您需要的颜色

Then change your color to color that you need

最后,将标签的颜色设置为 xcassets 目录中的颜色

Finally, set color of your label as this color from xcassets catalog

... 或以编程方式

label.textColor = UIColor(named: "ColorForLabel")

<小时>

现在当您需要更改文本颜色时,只需更改此颜色集

这篇关于使用 Swift 在整个应用程序中更改 UILabel 的 textColor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆