2014-01-21 2 views
2

Первый снимок экрана - это iOS7, который не то, что я хочу.
Первый снимок экрана - iOS6, что я хочу.Как удалить разделительную линию в iOS 7?

Стиль Tableview - простой.
Сепаратор стола нет.

И есть backgroudView этого темного цвета.

У меня есть код, как показано ниже

if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) 
    { 
     [tableView setSeparatorInset:UIEdgeInsetsZero]; 
    } 

cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"icon_bg_box.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]; 

enter image description here

enter image description here

ответ

9

Вам нужно добавить отдельный вид как разделитель Сначала сделайте tableViews Seperator к none

[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
     UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; 

    [cell addSubview:[self drawSeparationView:(indexPath.row)]]; 
     return cell; 
    } 

Затем проведите Ваш Seperator

- (UIView*)drawSeparationView:(NSInteger)itemNo { 
    UIView *view = [[UIView alloc] init]; 
    view.frame = CGRectMake(0, 0, self.tableView.frame.size.width, cellHeight); 

    UIView *upperStrip = [[UIView alloc]init]; 
    upperStrip.backgroundColor = [UIColor colorWithWhite:0.138 alpha:1.000]; 
    upperStrip.frame = CGRectMake(0, 0, view.frame.size.width, 2); 
    [view addSubview:upperStrip]; 

    UIView *lowerStrip = [[UIView alloc]init]; 
    lowerStrip.backgroundColor = [UIColor colorWithWhite:0.063 alpha:1.000]; 
    lowerStrip.frame = CGRectMake(0, cellHeight-2, view.frame.size.width, 2); 

    [view addSubview:lowerStrip]; 
    return view; 
} 

Выход будет что-то вроде этого

enter image description here

+1

Большое спасибо @Bishal – DipakSonara

1

Попробуйте

self.tableview.separatorColor = [UIColor clearColor]; 
+0

я попробовал это, но это Безразлично» т работ. – DipakSonara

4

Это скроет разделитель

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 

Затем добавьте свой пользовательский разделитель imageView в каждую ячейку внизу.

0

Если вы хотите, чтобы удалить разделительную линию tableviewcell

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 

Затем добавить разделитель для пользовательских ячейки

UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];/// change size as you need. 
separatorLineView.backgroundColor = [UIColor grayColor];// you can also put image here 
[cell.contentView addSubview:separatorLineView]; 

Кредиты перейти к iPatel Answer

Смежные вопросы