Ios4 是否更改tableView上的背景单元格?
我想更改tableView中所有单元格的背景,我使用了initWithStyle:UITableViewCellStyleValue1单元格的how类型(因为我想要此类型,但背景为白色),我不想更改tableView的背景,但只更改单元格,这可能吗 该样式的表格单元格由两个标签组成,一个标签左侧为主文本,另一个标签右侧为蓝色文本 尝试设置标签单元格的背景色:Ios4 是否更改tableView上的背景单元格?,ios4,Ios4,我想更改tableView中所有单元格的背景,我使用了initWithStyle:UITableViewCellStyleValue1单元格的how类型(因为我想要此类型,但背景为白色),我不想更改tableView的背景,但只更改单元格,这可能吗 该样式的表格单元格由两个标签组成,一个标签左侧为主文本,另一个标签右侧为蓝色文本 尝试设置标签单元格的背景色: tableCell.textLabel.backgroundColor = ... tableCell.detailTextLabel.b
tableCell.textLabel.backgroundColor = ...
tableCell.detailTextLabel.backgroundColor = ...
编辑:您还需要设置tableCell的contentView的背景色
tableCell.contentView.backgroundColor = ...
编辑2:以下代码还确保背景色延伸至附件
UIColor *bgColor = [UIColor greenColor];
tableCell.textLabel.text = @"abc";
tableCell.textLabel.backgroundColor = bgColor;
tableCell.detailTextLabel.text = @"def";
tableCell.detailTextLabel.backgroundColor = bgColor;
tableCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
tableCell.backgroundView = [[[UIView alloc] init] autorelease];
tableCell.backgroundView.backgroundColor = bgColor;
我用过:cell.contentView.backgroundcolor。。。但对于将颜色更改为cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;如何制作?首先,你可以扔掉上一段代码中最后两行以上的所有内容,如果你不设置textLabel和detailLabel的背景色,那么它们只会是白色的。(顺便说一句,第一次结果来自)