How to change a grouped UITableView cell's background to black (or non-white)?
Solution 1
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];
Solution 2
If you edit the cell.backgroundColor instead of the cell.contentView.backgroundColor it should work for you.
Meltemi
Updated on June 04, 2022Comments
-
Meltemi almost 2 years
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...
-
Vaerenberg almost 15 yearsYou want to change the background of your tableview or tableview cell? To change the bkg of the table, set the background of your view to black or whatever color you want. And in your viewcontroller, do this self.tableView.backgroundColor = [UIColor clearColor];
-
Meltemi almost 15 yearsI'm interested in changing the tableview cell's background. Thought I was clear in the description but I edited the title anyway.
-
-
FalconNL over 12 years+1 for set cell.backgroundView to nil and use cell.backgroundColor = [UIColor blackColor];