---
title: "iOS UItableviewcell  点按钮修改cell颜色"
author: "夜鸣猪"
date: "2013-03-20T10:58:54Z"
tags: []
categories: ["编程语言"]
slug: "ios-uitableviewcell-cell"
draft: false
lastmod: "2013-03-20T10:58:54Z"
id: 1832437
url: "https://hlee.iteye.com/blog/1832437"
---

```c


@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

```


[.](http://stackoverflow.com/questions/10213364/how-to-change-the-backgroundcolor-for-all-uitableviewcells)



```c


cell.backgroundView = [[[uiview alloc] init] autorelease]; 
cell.backgroundView.backgroundColor = self.cellColor;

```