Search code examples
iosobjective-cuitableviewios13uibackgroundcolor

iOS: the background color of the header of my TableView is not changing anymore in iOS13


My TableView's header is not displaying well in iOS13. No matter what color I put, it always displays a light gray now...

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{   //Section color & style

    UITableViewHeaderFooterView *v = (UITableViewHeaderFooterView *)view;

    v.backgroundView.alpha = 1;
    v.textLabel.textColor = sectionColor;
    v.textLabel.font = sectionFont;
    v.textLabel.numberOfLines = 1;
    v.textLabel.minimumScaleFactor = 0.5;
    v.textLabel.adjustsFontSizeToFitWidth = YES;
    v.backgroundView.backgroundColor = [UIColor blueColor];
} 

iOS12:
iOS12

iOS13: iOS13

It is strange because when I put a stop in the debugger in step by step, it displays me the good image in iOS13, but not in the app:

stepbystep Any suggestions, thanks in advance ?


Solution

  • This works for me.

    v.contentView.backgroundColor = .blue
    

    instead of

    v.backgroundView.backgroundColor = .blue