2013-03-04 274 views
1

我已经实现了以下代码,以便更改tableView中节标题的色调。我只想改变颜色的色调,而不是从我自己的角度应用视图。然而,该应用程序似乎忽略了它,而节标题仍以默认灰色显示。任何线索我可能做错了什么?非常感谢!更改UITableView标题色调颜色

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
    [[tableView headerViewForSection:section] setTintColor:[UIColor brownColor]]; 
    return [tableView headerViewForSection:section]; 
} 
+0

请google一下......当然U将得到答案@阿尔瓦罗·莫拉莱斯纳瓦罗 – Babul 2013-03-04 09:40:08

+0

参阅此http:// stackoverflow.com/questions/813068/uitableview-change-section-header-color @ÁlvaroMorales Navarro – Babul 2013-03-04 09:41:11

+0

谢谢巴布尔,我绝对使用了它几天。该解决方案不使用setTintColor方法,所以它不是我正在寻找的。无论如何感谢您的帮助。 :-) – 2013-03-04 10:53:16

回答

2

这是工作100%,你可以改变你的索引或标题文字颜色

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section 
{ 
    view.tintColor = [UIColor blueColor]; 

    // if you have index/header text in your tableview change your index text color 
    UITableViewHeaderFooterView *headerIndexText = (UITableViewHeaderFooterView *)view; 
    [headerIndexText.textLabel setTextColor:[UIColor blackColor]]; 

}