2010-03-03 84 views
0

我的問題很簡單....UITableView組風格單元格背景

如何擺脫組風格的單元格的白色背景顏色。

我知道clearColor,但它只是清除tableview本身的背景顏色,而不是單元格的背景顏色。

在此先感謝。

回答

1

UITableViewCell class有一個backgroundView property。對於正常表格視圖,這通常設置爲nil,但對於分組表格視圖則不是。試試這個:

if ([ cell backgroundView] != nil) { 
    [[cell backgroundView] setBackgroundColor:[UIColor redColor]]; 
} else { 
    // Create a view, set its frame to the cell's frame, and set its background 
    // color. 
} 

該代碼將單元格的背景顏色設置爲紅色,如果是在分組表視圖。

+0

那麼第一部分沒有工作。所以我刪除了if語句,而「else」部分像魅力一樣工作。 非常感謝。 – looneygrc 2010-03-03 04:36:57

相關問題