美文网首页
UITableViewCell选中UILabel背景色消失

UITableViewCell选中UILabel背景色消失

作者: CombatReadiness | 来源:发表于2019-01-22 10:00 被阅读11次

解决办法

  • 想要点击Cell依然有高亮效果,在Cell中写入
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    //自己的label及自己要设置的label背景色
    self.messageLabel.backgroundColor = [UIColor redColor] ;
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
    [super setHighlighted:highlighted animated:animated];
    //自己的label及自己要设置的label背景色
    self.messageLabel.backgroundColor = [UIColor redColor] ;
}
  • 想要点击Cell没有高亮效果,只需设置cell
cell.selectionStyle = UITableViewCellSelectionStyleNone;

相关文章

网友评论

      本文标题:UITableViewCell选中UILabel背景色消失

      本文链接:https://www.haomeiwen.com/subject/yttljqtx.html