1

I have implemented the following code in order to change the tint of the section headers in a tableView. I just want to change the color tint, not to apply a view from my own. The app, however, seems to ignore it and the sections headers keep being displayed with the default gray. Any clue about what could I be doing wrong? Thanks a lot!

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    [[tableView headerViewForSection:section] setTintColor:[UIColor brownColor]];
    return [tableView headerViewForSection:section];
}
  • Please google it ... Sure u will get answer @Álvaro Morales Navarro – Babul Mar 04 '13 at 09:40
  • see this http://stackoverflow.com/questions/813068/uitableview-change-section-header-color @Álvaro Morales Navarro – Babul Mar 04 '13 at 09:41
  • Thanks Babul, I definitely googled it for days. The solution is not using the setTintColor method, so it's not what I'm looking for. Thanks for your help anyways. :-) – Álvaro Morales Navarro Mar 04 '13 at 10:53
  • Thanks again! I finally found what I was looking for in http://stackoverflow.com/questions/3294876/changing-the-color-of-uitableview-section-headers – Álvaro Morales Navarro Mar 04 '13 at 12:17

1 Answers1

2

this is work 100% and you can change your index or header text color

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
    view.tintColor = [UIColor blueColor];

    // if you have index/header text in your tableview change your index text color 
    UITableViewHeaderFooterView *headerIndexText = (UITableViewHeaderFooterView *)view;
    [headerIndexText.textLabel setTextColor:[UIColor blackColor]];

}
codercat
  • 22,873
  • 9
  • 61
  • 85