如果你想要灰色那么
cell.selectionStyle=UITableViewCellSelectionStyleGray;
或者你可以设置背景颜色didSelectRow
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView reloadData];
UITableViewCell *cell=(UITableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
[cell setBackgroundColor:[UIColor orangeColor]];
}
如果您不想重新加载 tableData 那么您必须保存您的 previousSelected Index 值然后
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Make oreange cell
UITableViewCell *presentCell=(UITableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
[presentCell setBackgroundColor:[UIColor orangeColor]];
//make your previous cellBackgrod to clear, you can make it white as per your requirement
UITableViewCell *previouscell=(UITableViewCell*)[tableView cellForRowAtIndexPath:previousSelectedCellIndexPath];
[previouscell setBackgroundColor:[UIColor clearColor]];
//save your selected cell index
previousSelectedCellIndexPath=indexPath;
}