重写-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
[super setSelected:selected animated:animated];
if (selected) {
self.titlelable.textColor = THEME_COLOR;
}else{
self.titlelable.textColor = DEFAULT_COLOR;
}
}
在这个方法中可以通过选中与否动态的改变文字颜色等等;
下面是单独改变cell选中时的背景颜色为白色:
self.contentView.backgroundColor = [UIColor clearColor];
UIView *aView = [[UIView alloc]initWithFrame:self.contentView.frame];
aView.backgroundColor = [UIColor whiteColor];
self.selectedBackgroundView = aView;
本文介绍了一种在iOS开发中实现TableView Cell选中状态的方法,包括如何通过重写setSelected方法来改变文字颜色,以及如何设置Cell背景颜色。
2217

被折叠的 条评论
为什么被折叠?



