Why does [cell.detailTextLabel setBackgroundColor:[UIColor blackColor]]; not work?
[cell.detailTextLabel setBackgroundColor:[UIColor blackColor]];
doesn't wor开发者_开发问答k. Any way to make it work?
Thanks
The UITableViewCell
textLabel
and detailTextLabel
both don't behave like normal UILabel
's. This probably is because a UITableViewCell draws it's text instead of using a UILabel
for performance reasons. This results in inconsistent behaviour because the backgroundColor property is ignored by the cell's drawing.
Stick with the default UITableViewCell
if your desired functionality fits within what the Apple engineers have designed to be handled by a default cell. For all other functionality create your own subclass of UITableViewCell.
set this in table view delegate method
- (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath {
[cell.detailTextLabel setBackgroundColor:[UIColor blackColor]];
}
cell.detailTextLabel.textColor = [UIColor blackColor];
精彩评论