2013-03-17 48 views
2

我有一個包含兩個單元的分組UITableView。我爲表格視圖設置了一個自定義的separatorColor,但希望擺脫兩個單元格之間的內部分隔符,以便它看起來像一個單元格。我想讓外部分隔符圍繞單元格的邊緣。從兩個分組的UITableView單元中刪除內部分隔符

我現在擁有的一切:

A grouped table view with two cells and a visible separator

我想什麼來實現:

A grouped table view with two cells and no visible separator

這可能嗎?我的項目目標iOS 5.0及以上。提前致謝。

回答

1

這是否必須是一個動態表?你提到它只有兩個單元格..也許你可以看看讓表格/部分的一個單元格具有更大的行高?或者根本不把它放在桌子上?而是使用一個UIView:

#import <QuartzCore/QuartzCore.h> 

-(void)viewDidLoad 
{ 
    [myview.layer setBorderWidth:1]; 
    [myview.layer setBorderColor:[[UIColor lightGrayColor] CGColor]]; 
    [myView.layer setCornerRadius:20]; 
} 

上面的代碼將會給你你想要的只是換出myview變量的任何觀點圓角。

+0

不,它不是動態的。 – 2013-03-18 09:12:29

-1

嘗試添加

[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; 

或U可以添加

UIView *backgroundVie = [[UIView alloc] init]; 
backgroundVie.backgroundColor = [UIColor clearColor]; 
    cell.backgroundView=backgroundVie ; 
+0

這沒有什麼區別。 – 2013-03-17 11:13:50

+0

將單元格背景視圖設置爲清晰視圖允許表格視圖背景顯示。 – 2013-03-17 18:28:09

3

嘗試更改表視圖的分隔符樣式了。

tableView.separatorColor = [UIColor clearColor]; 
tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 
+0

這將刪除內部分隔符,但也會除去單元格邊緣外部的分隔符。 – 2013-03-17 11:14:15

+0

放置自己的背景圖像是個好主意。 – andykkt 2013-03-17 11:19:59

相關問題