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];
}
轉載于:https://www.cnblogs.com/fantasy940155655/p/6055480.html
總結
以上是生活随笔為你收集整理的UITableView 点击选中改变字体颜色并记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: eBay 第四季度营收 25.10 亿美
- 下一篇: 报告称 macOS 用户主要受广告软件困