目标C:如何为整个细胞添加颜色(带有披露指标)

Zhe*_*hen 10 objective-c background-color uitableview ios

我正在尝试为我的单元格添加背景颜色,但无法使用披露指示器为该部分着色(请参见下面的屏幕截图)

在此输入图像描述

我可以做些什么来为整个细胞着色?我的实现如下.

cell.contentView.backgroundColor = [UIColor colorWithHexString:@"#FFFFCC"];

//Clear colors for labels
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
Run Code Online (Sandbox Code Playgroud)

Noa*_*oon 12

UITableViewCell子类UIView; 您可以像设置任何其他视图一样设置其背景颜色."分组"式表格视图中的单元格需要更多工作,但它看起来并不像您正在使用它,因此:

cell.backgroundColor = [UIColor colorWithHexString:@"#FFFFCC"];
Run Code Online (Sandbox Code Playgroud)

  • cell.background color = [UIColor colorWithHexString:@"#FFFFCC"]如果我把代码放在方法中 - (void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath .它也涵盖了披露背后的领域. (7认同)