UITableViewHeaderFooterView does not honor appearance proxy's values when views are reused on grouped table views

Originator:steipete
Number:rdar://42749723 Date Originated:31-Jul-2018 12:39 AM
Status:Open Resolved:
Product:iOS + SDK Product Version:11.4 and 12b4
Classification:Other Bug Reproducible:Always
 
Summary:
We support theming in our application, and noticed that the colors for the headers and footers in our table view were colored incorrectly.

After much digging into our code, we realized that when a UITableView is created with a UITableViewStyleGrouped, the default UITableViewHeaderFooterView implementation does not respect the appearance proxy after the views are reused. That is, after the UITableViewHeaderFooterView, the textLabel's textColor property is reset to its default value.

If the table view is created with UITableViewStylePlain, the table view behaves correctly setting the label's text color to the correct value based on the UIAppearance proxy implemented.

The label color's are set using this code: 

        [UILabel appearanceWhenContainedInInstancesOfClasses:@[UITableViewHeaderFooterView.self]].textColor = UIColor.redColor;

This code does not work:

        [UITableViewHeaderFooterView appearance].textLabel.textColor = UIColor.redColor;


Steps to Reproduce:
1. Download the sample project attached, and run it in the simulator.
2. Interact with the table view, scrolling up and down.
3. Notice how the titles' and footers' colors change from red to their default value, ignoring the values set through the appearance proxy.

Expected Results:
The appearance value is honored even when the views are reused and the table view is using UITableViewStyleGrouped.

Actual Results:
The appearance value for the text color is ignored after the UITableViewHeaderFooterView view is reused with the table view using UITableViewStyleGrouped. This is a duplicate of radar #42745238

Version:
11.4 and 12b4

Notes:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!