I'm working with iOS 5 and have dynamically generated cells in a table (2 sections of 3 rows each). Each section has a header that is also dynamically generated using the titleForHeaderInSection
call.
I also have an image set as the background for the table that makes the default color of the section headers hard to read. I haven't found a way to change the color of the section headers (or shadow color
, font
, text size
, etc for that matter) either through the Storyboard interface or programmatically! Please help!
If you want to have table view header along with section headers you have to set UITableViewStyle property to UITableViewStyleGrouped . Show activity on this post. If you have a single header in the table then you can use tableHeaderView as below: tableView.
This also works in iOS5+. It applies to all of the section headers and footers in the tableview and suited my needs.
- (void)viewDidLoad
{
[super viewDidLoad];
[[UILabel appearanceWhenContainedIn:[UITableViewHeaderFooterView class], nil] setFont:[UIFont fontWithName:@"MyFont" size:8]];
}
Dan
You can modify the font size/color/etc by creating your own view for the section header using the method tableView:viewForHeaderInSection:
There's an example of this technique here
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