我试图设置自定义单元格的背景颜色,但不显示背景颜色.
ProjectListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[ProjectListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell... if((indexPath.row%2)!=0) { [cell setBackgroundColor:[UIColor redColor]]; } else { [cell setBackgroundColor:[UIColor greenColor]]; }
这是因为splitview.
解决方法
尝试使用cell.contentView.backgroundColor或cell.backgroundView.backgroundColor.