2011-12-13 79 views
3

tableView:viewForHeaderInSection:调整UITableViewCell标题部分字体颜色的最佳方法吗?如何设置UITableView节标题中的字体颜色?

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

回答

3

tableView:viewForHeaderInSection:返回一个UIView。您必须创建UIView,将UILabel添加到UIView中,并调整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; 
}