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];

}

posted @ 2016-11-11 20:07  樊特西style  阅读(680)  评论(0编辑  收藏  举报