iOS UItableviewcell 点按钮修改cell颜色


@interface MyTableViewController : UITableViewController {
    UIColor *cellColor;
}
-(IBAction)click:(id)sender;

@implementation MyTableViewController

    -(IBAction)click:(id)sender{
        cellColor = [UIColor redColor];
        [self.tableView reloadData];
    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // Setup your cell
        cell.textLabel.backgroundColor = [UIColor clearColor];
        cell.detailTextLabel.backgroundColor = [UIColor clearColor];
        cell.accessoryView.backgroundColor = [UIColor clearColor];
        cell.contentView.backgroundColor = cellColor;
        return cell;
    }

@end


.



cell.backgroundView = [[[UIView alloc] init] autorelease]; 
cell.backgroundView.backgroundColor = self.cellColor;

你可能感兴趣的:(UITableViewCell)