Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 846
prostock Avatar asked May 26 '11 00:05

prostock


People also ask

What is header in Swift?

For output message, the basic header identifies the application through which SWIFT has processed the message. The basic header also identifies the type of output data, the receiving logical terminal, and (if required) the output session number and output sequence number.


1 Answers

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

like image 91
justin Avatar answered Sep 22 '22 19:09

justin