2013-03-04 279 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]]; 

}