Aaron Wojnowski
Aaron Wojnowski

Reputation: 6480

White Separator Above Table Section Headers

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?

screenshots

Upvotes: 3

Views: 1727

Answers (2)

Jacob
Jacob

Reputation: 2338

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

Upvotes: 5

mxcl
mxcl

Reputation: 26893

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.

Upvotes: 2

Related Questions