2011-12-13 64 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; 
} 
相關問題