prostock
prostock

Reputation: 9545

Custom Section Title View for UITableView

In some apps such as Cool Iris, LiveShare, i see them using custom views for their plain UITableView section titles. Is there a way to replace the standard section title bar with a custom view?

Upvotes: 6

Views: 9108

Answers (1)

justin
justin

Reputation: 5831

In order to customize the look of your section header, there are two methods you will probably want to use.

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

and

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

These are both found in the UITableView delegate protocol. The first will let you create a custom view to display as your section header. The second just makes sure you get the size you want for it so that your view doesn't get cut off

Upvotes: 21

Related Questions