点击UITableCell颜色改变的问题

若点击后不想改变函数

在- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath这个函数中,直接调用[tableView 
deselectRowAtIndexPath:indexPath animated:NO];应该就能够了。
或者:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

这个代理中   加上一句 

cell.selectionStyle = UITableViewCellSelectionStyleNone;

若点击后为选中可是松手后不选中则能够这样:字体

在 didselect 代理方法里面添加一个 [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
就能够松开手后 颜色恢复啦。

若想要cell添加点击时改变字体的颜色及背景代理

cell.selectedBackgroundView.backgroundColor = [UIColor whiteColor];//选中后变换,色彩的变换
cell.textLabel.highlightedTextColor = [UIColor colorWithRed:0/255.0 green:180/255.0 blue:140/255.0 alpha:1];//选中label颜色的变化
cell.textLabel.textColor = [UIColor whiteColor];

cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fenlei-weidaidi"]];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fenlei-daidi"]];//选中后变换,图片的变换
相关文章
相关标签/搜索