2011-05-03 85 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;