Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent row of pixels between section header and first cell in a grouped UITableView

As the title says, I have a problem with a row of transparent pixels that I can't get rid off.
I attached an image as it's worth 1000 words.

The problem is not present for the section footer (where I'm also using a custom view). I have checked and double checked that I return the correct size for the height of the section.

Any ideas?

EDIT:
I've added a test project so you can play around. The purple color represents the background color. The white rectangles are the header/footer and the light gray are some dummy cells. The issue is clearly visible in the project.

TransparentRowBug XCode project

You will also see that I use a lot of clear colors. Unfortunately changing the colors in order to hide the problem is not a viable solution for me.

Feel free to give it a try (or more)!

Thanks a lot!

EDIT2:
After further investigation, I concluded that the line of pixels come from the tableview separator. In the test project I am setting the separatorColor to clearColor. If I change this to another color, I will get exactly that row of pixels in the new color. Even though I set the separator style to none, it seems to have no effect on grouped tables.

like image 403
Andrei Stanescu Avatar asked Apr 27 '11 23:04

Andrei Stanescu


1 Answers

I finally figured this one out, after almost 2 days of testing (and hair loss).

As I said in my comment above, simply returning a smaller height in the heightForHeader method doesn't work. To make it work you need to take your desired header view, insert it in a dummy/container view with the exact same size and then give this container to the tableView as the header.

Then, when you return a smaller size for the header, it magically (and it really is magic for me) manages to overlap that annoying row of pixels.

By the way, I concluded that the row of pixels is due to the cell separator line.

If someone is interested, I can upload the working test project again.

like image 156
Andrei Stanescu Avatar answered Sep 23 '22 04:09

Andrei Stanescu