【发布时间】:2015-03-15 16:05:32
【问题描述】:
我正在尝试让我的表格视图单元格在选中时显示自定义复选标记图像。问题是复选标记图像后面的颜色是灰色,而不是我提供的自定义单元格颜色。
我知道之前有人问过这个问题 - 我已经阅读并尝试了以下建议:
- Wrong Background Color in Accessory View on iOS7
- How to get Transparent Accessory View in UITableViewCell? (w/ Screenshot)
- Altering the background color of cell.accessoryView and cell.editingAccessoryView
等等。普遍的共识似乎是改变单元格backgroundView 的颜色会影响配件,但对我来说似乎并非如此。这是我当前的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryView = [[UIImageView alloc] initWithImage:_checkImage];
[self setCellColor:_customColor forCell:cell];
}
- (void)setCellColor:(UIColor *)color forCell:(UITableViewCell *)cell
{
cell.contentView.backgroundColor = color;
cell.backgroundView.backgroundColor = color;
cell.backgroundColor = color;
}
请注意,我的checkImage 具有透明背景。选择一个单元格后,我的单元格背景变为我的customColor,但附件上的背景仍然是灰色的。求救!
【问题讨论】:
标签: ios objective-c uitableview