美文网首页
点按UITableViewCell时改变cell上面的文字高亮或

点按UITableViewCell时改变cell上面的文字高亮或

作者: 蓝色的雪啦 | 来源:发表于2016-12-23 17:02 被阅读19次

点按某个Cell的时候cell上面的文字高亮或者改变颜色在具体的Cell中重写函数:

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
//重写高亮函数
 if (highlighted) { 
    self.textLabel.backgroundColor = [UIColor yellowColor]; 
    self.textLabel.textColor = [UIColor redColor]; 
    self.textLabel.text = [NSString stringWithFormat:@"这是第%ld行 点中我啦哈哈哈",(long)self.tag]; 
  } else {
    self.textLabel.backgroundColor = [UIColor clearColor]; self.textLabel.textColor = [UIColor blackColor]; 
    self.textLabel.text = [NSString stringWithFormat:@"这是第%ld行 哈哈哈",(long)self.tag]; 
  }
}

相关文章

网友评论

      本文标题:点按UITableViewCell时改变cell上面的文字高亮或

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