UITableViewHeaderFooterView textLabel.textColor

Hi,


I've an app where I use a UITableViewHeaderFooterView and modify some of it's attributes like the textLabel's textColor. I dodn't exaclty know when this started but currently (iOS 10 beta 6) when a new UITableViewHeaderFooterView is created, the textLabel's textColor is black (when logged to console), but it's displayed in some kind of gray color.

And as soon as views get reused a different color gets logged to console. My delegate method is quite simple:

- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UITableViewHeaderFooterView* view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"Header"];
    view.contentView.backgroundColor = [UIColor defaultGroupTableViewBackgroundColor];
    NSLog(@"%@", view.textLabel.textColor);
    view.textLabel.textColor = [UIColor blackColor];
    view.textLabel.text = [self tableView:tableView titleForHeaderInSection_:section];
    return view;
}

The problem is, when the view is created and it's textLabel's textColor is logged as black, the line 6 actually does nothing, because at that point the color is black already. But for some reason it is changed to

UIExtendedSRGBColorSpace 0.427451 0.427451 0.447059 1

later somewhere between returning it from the delegate method and displaying it.


When a view gets reused the above color is logged and changing it to black now seems to work as the text becomes black for these header views.


Did anyone know whats going on?


Dirk

Try logging textLabel.textColor in the -tableView:willDisplayHeaderView:forSection: delegate method. It is possible that the system is changing the text color between -tableView:viewForHeaderInSection: and that method.

Well, I set a breakpoint to stop the app, when the textColor changes and indeed the textColor is changed by the system for some reason. I didn't file a bugreport yet, but I think this could be considered as a bug. But it doesn't have high prio atm.


Dirk

Hi!
I noticed this problem long ago.
I use appearance class to set title/footer label color.

[UILabel appearanceWhenContainedInInstancesOfClasses:@[UITableViewHeaderFooterView.class]].textColor = self.sectionHeaderTitleColor;


Somehow, after section/footer disappears from screen, it redraws with default textColor. ( Gray color )

UITableViewHeaderFooterView textLabel.textColor
 
 
Q