我更改了我的UITableView
(带有图案图像)的backgroundColor,并且我希望我的单元格完全变白,我将backgroundColor
指定为cell.contentView
。我无法更改accessoryType
的backgroundColor
。我怎样才能做到这一点 ?无法更改tableView中的indicatorView.backgroundColor查看
这里是我有什么暂时的说明:
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *bgImg = [UIImage imageNamed:@"backgroundPattern.png"];
self.tableView.backgroundColor = [UIColor colorWithPatternImage:bgImg];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
// Put an arrow
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// In order to have my cell with a white background. I assign a whiteColor
// to my contentView because assign color to the cell.backgroundColor property doesn't
// to work..
cell.contentView.backgroundColor = [UIColor whiteColor];
// HERE is my problem, I would assign a backgroundColor of my accessoryType.
// Because for the moment, just behind the accessoryType this is a the color of the
// tableView.backgroundColor
cell.accessoryView.backgroundColor = [UIColor whiteColor];
}
// Configure the cell...
return cell;
}
如果我将我的颜色分配给contentView,它不起作用。这是因为它不会改变任何事情。显示的颜色是tableView.backgroundColor ... – klefevre
对不起,我错了。看我的编辑。 – LucasTizma
omg我忘了这个委托方法,我无法理解为什么Apple强制在这个方法中分配一个单元格backgroundColor,而不是在tableView:cellForRowAtIndexPath:无论如何 – klefevre