BrFreek
BrFreek

Reputation: 240

Grey separator line on top of uitableviewcell

I'm struggling with this for the last few hours and I cannot find a fix for it... In a UITableView I insert a list of custom UITableViewCells with all a different color. These colors are part of a UIView which acts as the backgroundView of the tableviewCell When I initialize the UITableView, I set

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

However, on each cell at the top there is still a thin gray line. This line is not from the textLabel (this label has a smaller frame then the actual cell) and neither from the UIView which contains the color (the layer.borderwidth = 0.0f and the color is clearColor).

Tableview with cells

EDIT

Okay, I found out that the lines do come from the UIView which contain the background color. However disabling them, leads to transparant cells when I reorder them, this is a result of the drawRect in this UIView with the folowing code to draw the UIView:

CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), true);
CGContextFillRect(UIGraphicsGetCurrentContext(), self.bounds);

Anyone knows a way to fix this?

SOLVED

Pretty stupid by me, but the cells didn't have a backgroundView... So by adding these two lines in the custom cell class the problem was solved!

self.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
self.backgroundView.backgroundColor = [UIColor whiteColor];

Upvotes: 2

Views: 2219

Answers (1)

BrFreek
BrFreek

Reputation: 240

I've found the solution to my question. By setting a UIView in the backgroundView of the cell class, and filling it with a white background color, this fixed the problem.

self.backgroundView = [[UIView alloc] initWithFrame:CGRectZero]; self.backgroundView.backgroundColor = [UIColor whiteColor];

Upvotes: 2

Related Questions