如何在UITableView的节头中设置字体颜色?

时间:2011-12-13 00:46:14

标签: ios uitableview colors header sectionheader

tableView:viewForHeaderInSection:是调整UITableViewCell标题部分中字体颜色的最佳方法吗?

我想简单地调整字体颜色(理想情况下),而不必定义UIView。我特别不愿意使用上面的方法,因为节标题的对齐在过去给我带来了麻烦。

1 个答案:

答案 0 :(得分:3)

tableView:viewForHeaderInSection:返回一个UIView。你必须创建一个UIView,在UIView中添加一个UILabel,并调整UILabel的字体。

例如:

{
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;
}
相关问题