I currently have a UITableView with multiple sections.
The header for each section is defined in the delegate like this (code adjusted for testing purposes):
[Export("tableView:viewForHeaderInSection:")]
public UIView GetViewForHeader(UITableView tableView, nint section)
{
var header = tableView.DequeueReusableHeaderFooterView("TestHeaderIdentifier");
if(header == null)
header = new UITableViewHeaderFooterView(new NSString("TestHeaderIdentifier"));
header.TextLabel.Text = "Section " + section;
header.TextLabel.TextColor = UIColor.Red;
header.ContentView.BackgroundColor = UIColor.FromRGB(124, 255, 190);
//.. Other customizations
return header;
}
This seems to work fine except for one bit, the TextColor of the label.
The above code results in the following:
The background color and text itself are applied fine, but the text color remains set to the default colour. What could be the cause of this issue?
I've already tried:
- Registering the header class on the table view instead of constructing it in the delegate method (using
RegisterClassForHeaderFooterViewReuse
) - Not reusing/dequeing the headers at all, constructing a new instance each time
Both to no avail.