2012-01-11 190 views
-1

我需要显示以下代码中附加的标签背景颜色。它是多行标签。如何设置标签背景颜色

这里是代码片段。

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

你是什么意思的“_show_标签背景颜色”? – phi 2012-01-11 15:59:27

回答

0

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

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

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

+0

我使用行数来动态显示文本标签..我想根据文本对齐显示文本的背景。现在我显示背景的标签按照帧的大小。 – 2012-01-12 05:48:51

+0

我有多行标签,它有动态文本。所以我需要显示每行的背景颜色。如果我设置self._coverTittle.backgroundColor背景有,但它显示标签的框架size.it应显示为背景作为行数。 – 2012-01-12 06:05:04

+0

@SubratTripathy意味着你需要几个颜色的单个标签,这取决于行..如果是这样,那么你可以参考-http://github.com/AliSoftware/OHAttributedLabel – rishi 2012-01-12 14:38:49