How to set the font color in a UITableView's section header?
-
14-03-2021 - |
Pergunta
Is tableView:viewForHeaderInSection:
the best way to adjust the font color in a UITableViewCell's header section?
I'd like to simply adjust the font color (ideally) without having to define a UIView
. I'm especially reluctant to use the above method since the alignment of section headers has given me trouble in the past.
Solução
tableView:viewForHeaderInSection: returns a UIView. You have to create a UIView, add an UILabel into the UIView, and adjust the font for the UILabel.
For example:
{
UIView *headerView = [[[UIView alloc]
initWithFrame:CGRectMake(0,0,self.view.frame.size.width, 30)] autorelease];
UILabel *label = [[UILabel alloc] initWithFrame:headerView.frame];
label.font = [UIFont systemOfFontWithSize:12];
....
return headerView;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow