2013-04-07 120 views
0

enter image description here如何從分組的UITableView的單元格中刪除邊框?

在底部的小白色條紋真的拋出了設計,我似乎無法弄清楚如何刪除它。

This問題有一個高額定應答說要做到這一點:

cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; 

但是,這(與setBackgroundColor:集)移除了我的背景,灰色以及因此它也不能工作。

回答

6

添加到您的viewDidLoad:刪除表格的邊框:

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 

我不明白你的問題非常好,但我建議你檢查你的背景視圖的高度,就像一個測試把圖像作爲單元格的背景圖,並檢查白線劇照有:

cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageName.png"]]autorelease]; 

// -----

您提供的代碼不工作貝科使用您正在創建一個新的空白的UIView並將其設置爲單元格背景的正確方法如下:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 

    static NSString *CellIdentifier = @"ApplicationCell"; 

    UITableViewCell *cell = (UITableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) { 

     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 

     UIView *myBackgroundView = [[UIView alloc] init]; 
     myBackgroundView.frame = cell.frame; 
     myBackgroundView.backgroundColor = [UIColor greenColor]; <== DESIRED COLOR 

     cell.backgroundView = myBackgroundView; 

    } 

    return cell; 

} 
+0

你的第一個代碼的建議優美的工作。謝謝。 – user212541 2013-04-07 23:28:25

+0

好吧,我很高興幫助你'user212541',檢查我的編輯,知道你爲什麼提供的代碼不工作! – Mateus 2013-04-07 23:29:35

+1

你是最棒的;謝謝。 – user212541 2013-04-08 00:25:38

1

試試吧

self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; 
+3

有一點解釋會很有用! :) – Parris 2013-04-07 23:45:56

相關問題