Kus*_*hok 3 xcode cocoa-touch objective-c uilabel
使用xCode 4.5.1接口构建器:
当我尝试使用RGB值更改标签文本的颜色属性时,背景颜色也会自动更改为相同的值.
换一种说法:
在为标签的文本颜色设置RGB值时,除非我们使用滑块,否则背景颜色也会发生变化.
如何确保只有文本的颜色而不是背景?
And*_*kha 12
UILabelclass有属性textColor和backgroundColor.你可以操纵它们.
label.textColor = [UIColor greenColor];
label.backgroundColor = [UIColor clearColor];
Run Code Online (Sandbox Code Playgroud)
要通过Interface Builder使用它,您应该选择标签,然后转到属性检查器.你会在那里找到名为Label的部分.那里有颜色标签.这是文本颜色.在Label Section下面有一个名为View的部分.它包含名为Background的选项卡.您可以在那里设置背景颜色