3

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

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

4

1 回答 1

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;
}
于 2011-12-13T01:02:24.170 回答