ITeye博客

iOS UItableviewcell 点按钮修改cell颜色

夜鸣猪 · 2013-03-20 10:58 · 编程语言 · Markdown



@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;

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。