You can change the background color of the UITableView section title

as a headline, can this be done?

+3
source share
2 answers

You will need to use

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 30;
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section       
{
    UIView *v = [[UIView alloc] init];
    [v setBackgroundColor:[UIColor blackColor]];
    return [v autorelease];
}

It was free, so forgive any typos, etc.

UPDATE: This only works for "grouped" tables. Is your table grouped or normal?

+4
source

Yes. Configure HeaderInSection using the method in the UITableViewDelegate Protocol:

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

When it returns the UIView, you can install it on whatever you like, or just

[UIView setBackgroundColor:UIColor];

0
source

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


All Articles