开发者

iPad: unable to set background color of custom cell in split view

开发者 https://www.devze.com 2023-02-14 23:34 出处:网络
I was trying to set the background color of a customized cell but background color is not displayed.

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) {
   开发者_如何学JAVA 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.


Try to use cell.contentView.backgroundColor or cell.backgroundView.backgroundColor instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消