UITableView 点击选中改变字体颜色并记录
//在这里判断,看indexPath是否已经被选中,如果选中就将其对应的那一行的字体颜色设置为选中时的颜色,否则就是默认的颜色
if ([_indexArray containsObject:indexPath]) {
cell.dateLabel.textColor = [UIColor grayColor];
cell.titleLabel.textColor = [UIColor grayColor];
cell.contentLabel.textColor = [UIColor grayColor];
}else{
cell.dateLabel.textColor = [UIColor darkGrayColor];
cell.titleLabel.textColor = [UIColor darkGrayColor];
cell.contentLabel.textColor =[UIColor darkGrayColor];
}
//记录选中的位置
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[_indexArray addObject:indexPath];
KnowledgeViewController * KnowVC = [[KnowledgeViewController alloc]init];
KnowVC.title = @"幼儿知识";
[self.navigationController pushViewController:KnowVC animated:YES];
}