I'm having a heck of a time getting a cell's backgroundView
to display.
The code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// assume cell is dequeued correctly (i.e. cell != nil)
UIView *backgroundView = [[UIView alloc] initWithFrame:cell.frame];
backgroundView.backgroundColor = [UIColor yellowColor];
cell.backgroundView = backgroundView;
[cell.backgroundView setNeedsDisplay];
return cell;
}
I also tried this in - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
. Still no luck.
I attempted subclassing the UIView
object used as the backgroundView and confirmed drawRect
is never being called.