White Separator Above Table Section Headers

萝らか妹 提交于 2019-12-12 15:10:44

问题


I'm having a really weird issue with table view separators. I have set the separator color to a dark gray which works great below the cells, but for some reason, there is a white separator before my section header (see the screenshot, above November). When I set the separator style to none, the line disappears which indicates that it is a separator. How can I remove this white separator line?


回答1:


- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, -1, 320, 2)];

    view2.backgroundColor = [UIColor blackColor]; // Your color
    view1.backgroundColor = [UIColor blackColor]; // Your color

    [view1 addSubview:view2];

    return view1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01;
}



回答2:


For me, this fixed it:

cell.backgroundColor = .clear

I was setting the cell’s backgroundView, but apparently the cell’s default color was shining through in some cases.



来源:https://stackoverflow.com/questions/25330784/white-separator-above-table-section-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!