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:
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:
 Any suggestions, thanks in advance ?
Any suggestions, thanks in advance ?  
I was noticing the same thing in one of my apps. Then saw a log message in the console:
Setting the background color on UITableViewHeaderFooterView has been deprecated. Please set a custom UIView with your desired background color to the backgroundView property instead.
Setting a custom UIView with the desired background color as the backgroundView of the UITableViewHeaderFooterView solved the problem.
Code sample
class SomeHeaderView: UITableViewHeaderFooterView {
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        configure()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func configure() {
        let backgroundView = UIView(frame: .zero)
        backgroundView.backgroundColor = .blue
        self.backgroundView = backgroundView
    }
}
This works for me.
v.contentView.backgroundColor = .blue
instead of
v.backgroundView.backgroundColor = .blue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With