I would like to customize both the background and the border color of a grouped-style UITableView.
I was able to customize the background color by using the following:
tableView.contentView.backgroundColor = [UIColor greenColor];
But the border color is still something I don't know how to change.
How do I customize these two aspects of the grouped-style table view?
I know the answers are relating to changing grouped table cells, but in case someone is wanting to also change the tableview's background color:
Not only do you need to set:
You also need to change or get rid of the background view:
You can customize the border color by setting
This task can be easily done using PrettyKit by adding about 5 lines of code. If you use
nib
files orstoryboard
, also do not forget to apply this little hack . When you use this approach, you should subclass your cell fromPrettyTableViewCell
:This is example of my
cellForRowAtIndexPath
:Much thanks to all who posted their code. This is very useful.
I derived a similar solution to change the highlight color for grouped table view cells. Basically the UITableViewCell's selectedBackgroundView (not the backgroundView). Which even on iPhone OS 3.0 still needs this PITA solution, as far as I can tell...
The code below has the changes for rendering the highlight with a gradient instead of one solid color. Also the border rendering is removed. Enjoy.
Thank you for the code, it's just what I was looking for. I have also added the following code to Vimal's code, to implement the case of a CustomCellBackgroundViewPositionSingle cell. (All four corners are rounded.)