2012-04-07 63 views
0

我嘗試這樣做:如何將表格視圖頁腳顏色設置爲與導航相同?

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 
{ 
    CGRect footerFrame = CGRectMake(0.0, self.tableView.bounds.size.height - kCustomRowHeight, self.tableView.bounds.size.width, kCustomRowHeight); 
    UIView *footerView = [[UIView alloc] initWithFrame:footerFrame]; 
    footerView.backgroundColor = self.navigationController.navigationBar.backgroundColor; 
    return footerView; 
} 

但是,使頁腳視圖不可見。

但這個工程:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 
{ 
    CGRect footerFrame = CGRectMake(0.0, self.tableView.bounds.size.height - kCustomRowHeight, self.tableView.bounds.size.width, kCustomRowHeight); 
    UIView *footerView = [[UIView alloc] initWithFrame:footerFrame]; 
    footerView.backgroundColor = [UIColor redColor]; 
    return footerView; 
} 

所以,我怎樣才能使頁腳具有相同的背景顏色和導航欄?

回答

1

這是一個真正的痛苦,爲什麼你嘗試閱讀navigationController屬性,我不明白爲什麼footerView是不可見的。然而,對於你目前的問題......你爲什麼不嘗試通過設置你自己的RGB與alpha值來複制顏色?

相關問題