2012-10-11 84 views
0

我想將我的customTableViewCell的背景設置爲黑色。經過一些搜索後,最常見的答案是在我的CellForRowAtIndex中執行此操作。設置自定義tableviewCell的背景

cell.contentView.backgroundColor = [UIColor clearColor]; 
cell.backgroundColor = [UIColor blackColor]; 

但它沒有幫助。有誰能夠幫助我?

在此先感謝!

+0

你把這個放在'if(cell == nil)'之外嗎?如果是的話,我不明白爲什麼它不應該工作。 – Cal

回答

1

如下操作,並保持一件事記住任何子視圖要添加的內容查看應該在我的情況clearcolor.As我有默認爲textLabel,所以我把它設置爲鮮明的色彩。

cell.textLabel.backgroundColor = [UIColor clearColor]; 
    cell.contentView.backgroundColor = [UIColor blackColor]; 
+0

它工作!謝謝 ! – Steaphann

+0

歡迎!很高興幫助你... –

0

設置的背景如下: cell.contentView.backgroundColor = [的UIColor blackColor];