views:

40

answers:

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

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

Thanks

+1  A: 

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.

Joris Kluivers
hmm, fair enough. :) it was an attempt to solve another problem, and not a necessity. :)
Thomas Clayson
A: 

set this in table view delegate method

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

}
Gyani
A: 

cell.detailTextLabel.textColor = [UIColor blackColor];

dhii