How can we change the font of tableview header?

前端 未结 5 996
灰色年华
灰色年华 2021-01-30 07:51

I am using some background color for the tabelView and style is grouped. The text in the header for the sections is not clear so I need to modify the the text color so that the

5条回答
  •  不思量自难忘°
    2021-01-30 08:32

    - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
        [((UITableViewHeaderFooterView *) view).textLabel setFont:[UIFont fontWithName:@"Your-Font-Name" size:((UITableViewHeaderFooterView *) view).textLabel.font.pointSize]];
    }
    


    Notes:

    • This will set the font to a custom font but keep the pointSize the same.
    • Also works for willDisplayFooterView.
    • Don't forget to change Your-Font-Name to your font.

提交回复
热议问题