How to remove separator gap between UITableViewCells

1.2k views Asked by At

I want to set an UIImageView on each of my custom UITableViewCell, however I want it to look like the images all join up. As it stands now I have moved the cell separator so that it doesn't cut over the top of the images, however I now need to work out a way to stop it taking up a couple of pixels inbetween each cell.

In the end I want to make the following black line join up seamlesly but still retain the seperator to the right. I have tried the following logic which uses an offset, however that didn't seem to work.

// This seems to shift the separator to the right which is good, however I want to get rid of the white line completely...
self.separatorInset = UIEdgeInsets(top: -1, left: 75, bottom: 0, right: 0)

Does anyone have any ideas on how I can achieve this?

enter image description here

1

There are 1 answers

2
Sulthan On BEST ANSWER

First to explain how the separator works: The separator is a subview of the cell, your content is usually inside the cell's content view.

To overlap the separator, you have two options:

  1. Remove it completely using table.separatorStyle = UITableViewCellSeparatorStyleNone and add your own separator.

  2. If you want the image to overlap the separator, add it directly to the cell, not to the content view.