2011-05-03 86 views
19

当重写(组风格)表格视图的页眉/页脚时,页眉和页脚字体应使用什么颜色以确保页眉和页脚字体与标准页眉和页脚一致字体?UITableView页眉/页脚字体颜色

头被加载这样的:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { 
     if(myHeaderView == nil) { 
      [[NSBundle mainBundle] loadNibNamed: @"MyHeaderView" 
              owner: self 
             options: nil]; 
     } 
     return myHeaderView; 
} 
+0

同样的问题,但对于iOS 7? – 2014-03-03 07:34:51

回答

42

从这个discussion

下面是的tableView头的UILabel信息上的iOS 6

Plain 
fontName: Helvetica-Bold 
pointSize: 18.000000 
textColor: UIDeviceWhiteColorSpace 1 1 
shadowColor: UIDeviceWhiteColorSpace 0 0.44 
shadowOffset: CGSize 0 1 


Grouped 
fontName: Helvetica-Bold 
pointSize: 17.000000 
textColor: UIDeviceRGBColorSpace 0.298039 0.337255 0.423529 1 
shadowColor: UIDeviceWhiteColorSpace 1 1 
shadowOffset: CGSize 0 1 

由于为简单样式标题的背景,tha t是一个UIImage,而不仅仅是一个backgroundColor。注意细微的垂直渐变。

希望它有助于

+3

对于分组的tableView页脚,除了字体是正常的权重 - 不是粗体,点的大小是15,所有内容都与页脚相同。 – yuji 2012-02-02 14:37:55

+0

“至于简单样式页眉的背景,这是一个UIImage,而不是简单的backgroundColor。注意细微的垂直渐变。“实际上,所有标签都有透明的背景颜色(全alpha)。渐变来自表视图的背景。在iOS中,对于分组表格视图甚至还有一种特殊的“颜色”渐变。 ;-) – 2012-03-23 18:17:14

+0

如何将所有这些编程设置到我的UILabel文本中? – mskw 2012-08-30 19:40:46

2

这对我的作品(页脚),带标签的CGFrame,其numberOfLines的一些摆弄它可能会为你工作:

int height = [self tableView:table heightForFooterInSection:section]; 

UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, table.bounds.size.width - 20, height)] autorelease]; 
label.text    = [self tableView:table titleForFooterInSection:section]; 
label.textColor   = [UIColor colorWithRed:0.298 green:0.337 blue:0.423 alpha:1.000]; 
label.font    = [UIFont systemFontOfSize:15.0]; 
label.backgroundColor = [UIColor clearColor]; 
label.shadowColor  = [UIColor whiteColor]; 
label.shadowOffset  = CGSizeMake(0, 1); 
label.textAlignment  = UITextAlignmentCenter; 
label.numberOfLines  = 2;