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.
user1639164 ,you can use header. backgroundView. backgroundColor=[UIColor blackColor]; to set the tint for the header background.
Basic Swift Code for iOS Apps For changing the background color of the table view cell, you should change the contentView. backgroundColor property of the cell. Now run the project to see the effect.
A view that presents data using rows in a single column. iOS 2.0+ iPadOS 2.0+ Mac Catalyst 13.1+ tvOS 9.0+
With the newer UIAppearance way of doing things, in versions > iOS 6.0 you can just do, for example:
[[UITableViewHeaderFooterView appearance] setTintColor:[UIColor redColor]];
With UIAppearance you can change UILabel
text color on your UITableView
headers like this:
[[UILabel appearanceWhenContainedIn:[UITableViewHeaderFooterView class], nil] setTextColor:[UIColor whiteColor]];
[[UILabel appearanceWhenContainedIn:[UITableViewHeaderFooterView class], nil] setShadowColor:[UIColor whiteColor]];
Should work on iOS 6.0+. Can be called anywhere (viewDidLoad
etc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With