我有一个基于Storyboard原型单元格的自定义
现在我遇到了一个奇怪的问题,就是在iOS7上,选中后单元格会完全变成蓝色,标签不再可见。看起来像是单元格被覆盖了前景色。在iOS7之前的所有iOS版本上都能正常工作。
可能是什么原因呢?
UITableViewCell
。在我的自定义单元格类中,我根据单元格状态“selected”或“highlighted”对单元格进行着色,代码大致如下:- (void)updateCellDisplay {
if (self.selected || self.highlighted) {
self.label.textColor = [UIColor whiteColor];
self.backgroundColor = [UIColor myLightBlueColor];
} else {
self.label.textColor = [UIColor blackColor];
self.backgroundColor = [UIColor whiteColor];
}
}
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
[self updateCellDisplay];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
[self updateCellDisplay];
}
现在我遇到了一个奇怪的问题,就是在iOS7上,选中后单元格会完全变成蓝色,标签不再可见。看起来像是单元格被覆盖了前景色。在iOS7之前的所有iOS版本上都能正常工作。
可能是什么原因呢?
UIView *selectedBackgroundView = [[UIView alloc] initWithFrame:drawerCell.frame]; selectedBackgroundView.backgroundColor = [UIColor customLightBlueColor]; drawerCell.selectedBackgroundView = selectedBackgroundView;
它覆盖了UITableViewCell内容视图中的所有其他视图。这只会在iOS7上发生。我认为这是一个错误。有人知道解决方法吗? - Stefan Arn