0

我设置了单元格[cell.contentView addSubview:chatView]。chatView 有一个UIImageView、两个UILabels和 UILabel backgroundColor = [UIColor clearColor]

编辑表格时,我选择单元格,单元格突出显示,UILabel backgroundColor 更改突出显示的颜色。如何取消 backgroupColor。

4

4 回答 4

1
theLabel.layer.backgroundColor = myColor

这工作得很好。

于 2015-09-24T10:36:41.897 回答
0

如果您只想不突出显示单元格选择,您可以这样做:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

我不确定您是否要取消标签 BgColor 或单元格

于 2012-04-06T02:41:15.767 回答
0

如果您不希望所选单元格更改其背景颜色,请将selectionStyle单元格的属性设置为UITableViewCellSelectionStyleNoneIe:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

标签的背景颜色设置为单元格的突出显示颜色的原因是因为您已将标签的背景颜色属性设置为清除颜色。

让我知道这是否可以解决您的问题。

于 2012-04-06T04:13:42.883 回答
0
- (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

于 2012-04-07T04:00:25.920 回答