如何删除iOS 7中的分隔线?
第一个屏幕截图是不是我想要的iOS7。
第一个截图是我想要的iOS6。
Tableview的风格很简单。
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] ];
你需要添加单独的视图作为分隔符首先使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; }
然后画出你的分隔符
- (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; }
输出将是这样的
这将隐藏分隔符
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
然后在底部的每个单元格中添加自定义分隔符imageView。
尝试这个
self.tableview.separatorColor = [UIColor clearColor];
如果你想删除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 答案