1
[cell.detailTextLabel setBackgroundColor:[UIColor blackColor]];

不起作用。有什么办法让它工作吗?

谢谢

4

3 回答 3

1

UITableViewCell textLabel和两者的detailTextLabel行为都不像正常UILabel的。UILabel这可能是因为 UITableViewCell出于性能原因绘制它的文本而不是使用 a 。这会导致不一致的行为,因为单元格的绘图忽略了 backgroundColor 属性。

UITableViewCell如果您想要的功能符合 Apple 工程师设计的由默认单元处理的功能,请坚持使用默认值。对于所有其他功能,请创建您自己的 UITableViewCell 子类。

于 2010-10-21T09:23:02.993 回答
0

在表视图委托方法中设置它

- (void)tableView: (UITableView*)tableView   willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath {
[cell.detailTextLabel setBackgroundColor:[UIColor blackColor]];

}
于 2010-10-21T09:29:37.750 回答
-3

cell.detailTextLabel.textColor = [UIColor blackColor];

于 2010-10-21T10:18:31.270 回答