2012-08-28 70 views
0

我有一個tableview節標題,爲此我想添加一個自定義視圖。當桌面視圖加載時,它顯示爲黑色,如下所示:http://postimage.org/image/luluolc57/當我開始滾動時,標題「粘」到屏幕/導航欄的頂部,它就變成我想要的樣子 - 這裏顯示的是http://postimage.org/image/lek98nxud/自定義Tableview節標題全部是黑色

基本上,我希望這個視圖對這個灰色圓圈透明,所以桌面視圖背景會顯示出來。這裏是相應的代碼。

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
    return [[SummaryView alloc] init]; 
} 


- (void)drawRect:(CGRect)rect 
{ 
    CGRect tintSize = CGRectMake(0.0, 0.0, self.bounds.size.height, self.bounds.size.height); 
    [[UIImage imageNamed:@"Circular Tint.png"] drawInRect:tintSize]; 
} 
+0

你的UITableViewDataSource/UITableViewDelegate實現的其餘部分是什麼樣的?我有預感,但想看更多。 –

回答

0

它是否像標準的UILabel一樣按預期工作?

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
    UILabel* label = [[UILabel alloc] init]; 
    [label setText:@"TEST"]; 
    return label; 
} 

如果是這樣,您可以慢慢嘗試從中轉換並查看問題出現在什麼時候。當它是alloc和init時,它可能與你的自定義視圖的大小有關。也許initWithFrame會解決它。