如何在iOS 7中删除分隔线?

Dip*_*ara 2 cocoa-touch objective-c uitableview ios ios7

第一个截图是iOS7,不是我想要的.
第一个截图是iOS6,我想要的.

Tableview的风格很简单.
Tableview的分隔符是none.

还有一个深灰色的背景视图.

我有如下代码

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] ];
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

在此输入图像描述

Bis*_*ire 9

您需要添加单独的视图作为分隔符首先使tableViews分隔符为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;
    }
Run Code Online (Sandbox Code Playgroud)

然后绘制你的分离器

- (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;
}
Run Code Online (Sandbox Code Playgroud)

输出将是这样的

在此输入图像描述