2012-01-11 198 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