I was trying to set the background color of a customized cell but background color is not displayed.
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]];
}
Is this because of splitview.
尝试使用cell.contentView.backgroundColor
或cell.backgroundView.backgroundColor
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.