我设置了单元格[cell.contentView addSubview:chatView]
。chatView 有一个UIImageView
、两个UILabels
和 UILabel backgroundColor = [UIColor clearColor]
。
编辑表格时,我选择单元格,单元格突出显示,UILabel backgroundColor 更改突出显示的颜色。如何取消 backgroupColor。
我设置了单元格[cell.contentView addSubview:chatView]
。chatView 有一个UIImageView
、两个UILabels
和 UILabel backgroundColor = [UIColor clearColor]
。
编辑表格时,我选择单元格,单元格突出显示,UILabel backgroundColor 更改突出显示的颜色。如何取消 backgroupColor。
theLabel.layer.backgroundColor = myColor
这工作得很好。
如果您只想不突出显示单元格选择,您可以这样做:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
我不确定您是否要取消标签 BgColor 或单元格
如果您不希望所选单元格更改其背景颜色,请将selectionStyle
单元格的属性设置为UITableViewCellSelectionStyleNone
Ie:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
标签的背景颜色设置为单元格的突出显示颜色的原因是因为您已将标签的背景颜色属性设置为清除颜色。
让我知道这是否可以解决您的问题。
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
if (self.editing) {
for (UIView *view in self.contentView.subviews) {
for (UIView *subview in view.subviews) {
if ([subview isMemberOfClass:[UILabel class]]) {
subview.backgroundColor = [UIColor clearColor];
}
}
}
}
}
我继承了 UITableViewCell,并重写了方法- (void)setSelected:(BOOL)selected animated:(BOOL)animated