iOS -tableView在Grouped样式下去掉section分割线

self.tableview = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped];
self.tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
 [self.view addSubview: self.tableview];

理论上来讲写完上面的cell的分割线没有了,但是我需要很多个section,带header的,因为不需要footer,习惯上我会把footer的高度设置为0.1,(因为不设置的话会默认显示,高度目测是20的浅灰条)

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *footerView = [UIView new];
    footerView.backgroundColor = [UIColor redColor];
    return footerView;
}

写完发现每个section的headerView上面都有一条灰色的分割线,这条灰色的线后来证实不是分割线,就是自己设置的高度为0.1的footerView
不知道有什么办法能让这个footer不显示,所以就将footer的背景色设置成了和headerView一样的颜色,视觉上最起码看不到

----------------------------------------此刻我还是因为一条线在加班------------------
夜间模式下cell上老有一根线,后来发现这线是cell.backGroundColor没改成夜间模式颜色,之前只设置了cell.contentView.backgroundColor的问题

你可能感兴趣的:(iOS -tableView在Grouped样式下去掉section分割线)