bgfriend0
bgfriend0

Reputation: 1152

How to change style of font in header section of grouped tableView while using static content via storyboard

I have used storyboard to design a grouped tableView with simple, static content. I want to change the look of the section headers, but storyboard does not seem to offer this functionality, and I cannot determine how to get programmatic access to the section headers without building the interface from code.

For reference, the following SO question fully resolves the problem in the case that the dataSource is dynamic.

How to change text color for Section Headers in a Grouped TableView in iPhone SDK?

Is a similar solution possible where the content is STATIC and I am NOT implementing the UITableViewDataSource protocol?

Upvotes: 2

Views: 2750

Answers (3)

software evolved
software evolved

Reputation: 4352

Here's an alternative approach. It will change the font size of ALL table headers and footers, which is one potential drawback, but it is simpler than the approach above I think

[[UILabel appearanceWhenContainedIn:[UITableViewHeaderFooterView class],nil] setFont:[UIFont systemFontOfSize:24.0f]];

Upvotes: 3

avdyushin
avdyushin

Reputation: 1946

You can not do this via Storyboard and static cell, only table header, table footer, cells can use your custom views.

Upvotes: 0

Chris
Chris

Reputation: 1683

If I remember correctly, you can click on a UIView object and drag it to the top of your table view in storyboard, and it will serve as it's header:

Otherwise, many of the tableview's delegate (not datasource) methods are still available even for static table views. So the delegate method:

-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

Will still be called. In here you can create a customized view to return as the header. This UIView can be created programmatically or in a .xib or storyboard view controller (via UIViewController.view).

Edit 1:

The drag and drop is for the UITableView's header, not the section. However, the method above will return a custom view for each section's header.

Upvotes: 2

Related Questions