Hi Im trying to change the text color of a UILabel in one of my views but having no luck.
你好,我正在修改一个UILabel的文本颜色,但是没有运气。
Is there something quite obvious that Im not doing in this code?
在这段代码中,是否有什么事情是很明显的?
self.nameTopRight.backgroundColor = [UIColor redColor];
self.nameBottomRight.textColor = [UIColor redColor];
4 个解决方案
#1
6
They need to be connected in Interface Builder.
它们需要在接口构建器中连接。
#2
5
The question was already answered for the OP, but for the sake of other people who come here trying to change a label's text color, use the textColor
property:
这个问题已经在OP中得到了回答,但是为了其他试图改变标签文本颜色的人,请使用textColor属性:
Swift
斯威夫特
myLabel.textColor = UIColor.red
Objective-C
objective - c
myLabel.textColor = [UIColor redColor];
#3
2
you can also set RGB colors likw this
你也可以设置RGB颜色,像这样
myLabel.textColor= [UIColor colorWithRed:(160/255.0) green:(97/255.0) blue:(5/255.0) alpha:1] ;
#4
0
Text color is the correct one, may be mistake in connections,
文本颜色是正确的,可能是错误的连接,
backgroundcolor is used for the label background color and for the textcolor use property textcolor
背景色用于标签背景色和textcolor use属性textcolor
#1
6
They need to be connected in Interface Builder.
它们需要在接口构建器中连接。
#2
5
The question was already answered for the OP, but for the sake of other people who come here trying to change a label's text color, use the textColor
property:
这个问题已经在OP中得到了回答,但是为了其他试图改变标签文本颜色的人,请使用textColor属性:
Swift
斯威夫特
myLabel.textColor = UIColor.red
Objective-C
objective - c
myLabel.textColor = [UIColor redColor];
#3
2
you can also set RGB colors likw this
你也可以设置RGB颜色,像这样
myLabel.textColor= [UIColor colorWithRed:(160/255.0) green:(97/255.0) blue:(5/255.0) alpha:1] ;
#4
0
Text color is the correct one, may be mistake in connections,
文本颜色是正确的,可能是错误的连接,
backgroundcolor is used for the label background color and for the textcolor use property textcolor
背景色用于标签背景色和textcolor use属性textcolor