Search code examples
iphoneuitableviewdetailtextlabel

Why does [cell.detailTextLabel setBackgroundColor:[UIColor blackColor]]; not work?


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

doesn't work. Any way to make it work?

Thanks


Solution

  • 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.