2012-04-18 28 views
2

基本的分隔符看起來非常簡單,只有一個區別,但大多數表格視圖都有一個好看的分隔符,我看起來很好,因爲它有陰影或使它看起來像3D的東西。他們如何呢?如何創建UITableView分隔符看起來不錯?

+4

http://stackoverflow.com/questions/1374990/how-to-customize-tableview-seperator-in-iphone http://stackoverflow.com/questions/2227420/iphone-uitableview-放置圖像的分隔符 http://stackoverflow.com/questions/4804632/uitableview-separator-line – 2012-04-18 09:58:44

回答

2

你可以用編程方式/ XIB創建你的表。 現在,無論是在你的代碼或XIB集:

yourTable.separatorStyle=UITableViewCellSeparatorStyleNone; 
現在

中的tableview委託方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier]; 
    if (cell == nil) 
    { 

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


     customSeperator=[[UIView alloc]initWithFrame:CGRectMake(0, (cell.frame.origin.y), 320, 1)]; 
     customSeperator.backgroundColor=[UIColor lightGrayColor]; 

     [cell.contentView addSubview:customSeperator]; 
} 

現在線(customSeperator.backgroundColor =的UIColor lightGrayColor]),你也可以嘗試

[UIColor colorWithPatternImage:[UIImage imageNamed:@"myimage.png"]]; 

使用您自己的圖像。 希望它能幫助你

+0

謝謝,最終我創建了包含分隔符的我的單元格的背景圖像,我認爲這是最好的我的解決方案:) – Eyal 2012-04-26 08:38:33

+0

很高興我能幫助你 – Alok 2012-04-30 09:27:26

相關問題