Iphone – How to change a grouped UITableView cell’s background to black (or non-white)


Just want to make sure I'm not overlooking something obvious… It seems like it should be trivial to set the background color (black is fine) of a UITableView's cell to something other than white or completely transparent so that you can display your data with white text. However, with my attempts I lose the corners on my grouped table view and it all looks like crap.

I've seen & understand the methods described by Matt Gallagher about customizing TableView cells with exotic gradients, etc. but wanted to be certain before heading down that path…

Best Solution

I believe that the rounded corners of the Grouped style are actually backgrounds of the table cells. Thus you can't just replace the white part, because it's not solid color with drawn border - it's ImageView acting as backgroundView for the cell (using different graphics depending of the cell row and number of rows in section).

So either you try with your own graphics so you can keep the roundness (I'm trying something out for myself, not fully figured yet) or set each cell.backgroundView to nil and use cell.backgroundColor = [UIColor blackColor];