View custom section title for UITableView

In some applications, such as Cool Iris, LiveShare, I see them using custom views for their simple headers in the UITableView section. Is there a way to replace the title bar of a standard section with a custom view?

+6
source share
1 answer

You can use two methods to customize the appearance of the section title.

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

and

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

They are in the UITableView delegated protocol . The first will allow you to create a custom view to display as the section title. The second simply ensures that you get the size you need so that your look is not cropped.

+21
source

Source: https://habr.com/ru/post/889059/


All Articles