如何设置标签背景颜色

时间:2012-01-11 15:56:13

标签: iphone ios uilabel

我需要显示以下代码中附带的标签背景颜色。这是多线标签。

以下是代码段。

self._coverTittle =[[FontLabel alloc] initWithFrame:CGRectMake(100, 650, 400, 200) fontName:@"futurlig-webfont" pointSize:48.0f];

self._coverTittle.backgroundColor = [UIColor colorWithRed:0 green: 0 blue:0 alpha:0.4]; 
_coverTittle.numberOfLines = 5;
_coverTittle.textColor = [UIColor whiteColor];

self._coverTittle.tag=5;
[self._coverTittle sizeToFit];

2 个答案:

答案 0 :(得分:0)

你做了什么应该工作:.backgroundColor。 如果你想要textcolor,你应该.textColor。 但你的问题有点不清楚,请澄清。

答案 1 :(得分:0)

 self._coverTittle.backgroundColor = [UIColor colorWithRed:0 green: 0 blue:0 alpha:0.4];

如果要设置标签的背景颜色,则需要传递红色,绿色和蓝色部分的值。 以下链接包含相同的完整文档 - http://chris-software.com/index.php/tag/rgb-colors/