具体的步骤是三个,第一步设定cell选择状态下的背景view
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
cell.selectedBackgroundView.backgroundColor = [UIColor orangeColor];
此时记得不要设置点击类型为none
第二步在didSelectRowAtIndexPath的选择方法里面执行下面代码,这句代码是用来延迟执行的,因为我的需求是点击后变回原样
[self performSelector:@selector(cancleSelect) withObject:nil afterDelay:0.1f];
- (void)cancleSelect
{
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
}
这样就可以达到点击cell变色,放开后恢复的效果了