表部分标题上方的白色分隔符

时间:2014-08-15 16:58:57

标签: ios objective-c uitableview separator

我对表视图分隔符有一个非常奇怪的问题。我已将分隔符颜色设置为深灰色,在单元格下方工作得很好,但出于某种原因,在我的节标题之前有一个白色分隔符(请参见11月上方的屏幕截图)。当我将分隔符样式设置为none时,该行消失,表示它是分隔符。如何删除此白色分隔线?

screenshots

2 个答案:

答案 0 :(得分:5)

- (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;
}

答案 1 :(得分:2)

对我来说,这解决了它:

cell.backgroundColor = .clear

我正在设置单元格的backgroundView,但显然在某些情况下单元格的默认颜色正在闪烁。