Iphone – Changing the color of UITableView section headers

iphoneuikituitableview

OK, I know that this has been asked previously, so please forgive me for asking again. It just seems like there has got to be an easier way to do this.

Is there a 'simple' way to change the UITableView section header background color? I know that I can use the delegate method 'viewForHeaderInSection' to hand the UITableView a custom UIView to use for the section headers, but all I really want to do is set the 'tintColor'. There is a tintColor property on the search bar, why not for the section headers.

If I use viewForHeaderInSection to create my own custom UIView, I have to create my own label as well. I have to style and position my label to look just like the rest of the Apple standard. I have to style and size the 'background' to look like the rest of the Apple standard.

I can't find a way to simply ask for the section header and then change it's color. Am I missing something or do I really have to do this the hard way.

If I have to do this the hard way, does someone have all of the styling information that matches the Apple standard?
– bar is 'translucent'
– bar has some shading on the top and the bottom
– label has a certain size, position, shadings, etc

Thanks. And once again, sorry for asking this question again.

Best Answer

With the newer UIAppearance way of doing things, in versions > iOS 6.0 you can just do, for example:

[[UITableViewHeaderFooterView appearance] setTintColor:[UIColor redColor]];