简体   繁体   English

如何分配窗口色调颜色以动态查看背景色或标签文本颜色-iOS

[英]How to assign window tint color to view background color or lable text color dynamically- iOS

In the storyboard, we have the option to change Global tint color as shown below: 在情节提要中,我们可以选择更改“整体色调”颜色,如下所示: 在此处输入图片说明

Is there any way to assign same tint color to Lable text color using storyboard? 有没有办法使用情节提要为Lable文本颜色分配相同的色调颜色? as I don't want to create the new reference of the label to change color only. 因为我不想创建标签的新引用以仅更改颜色。

And when I will change global tint color then all text field text color should be changed. 当我更改全局色时,所有文本字段的文本颜色都应更改。

There is no way to apply label color globally from storyboard. 无法从情节提要中全局应用标签颜色。 But you can create Custom Label Class in which you can set default color for label. 但是您可以创建自定义标签类,在其中可以设置标签的默认颜色。 Finally assign that class in identity inspector of every label you have added in storyboard by selecting label. 最后,通过选择标签,在添加到情节提要中的每个标签的身份检查器中分配该类。

    class CustomLabel: UILabel {
    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)!

        //you can set your properties
        //e.g
        self.textColor = UIColor.darkGray
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM