2010-03-03 89 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