The Hit List Diary #13 – Table separator insets

Since iOS 7, the standard setup for a table view has been to draw the separator lines between cells with an inset on the left-hand side. Usually this inset aligns with the cell’s text.

The inset can be customised, both at the table level, and for individual cells, with the .separatorInset property. Which one you set depends entirely on your needs, but it’s probably worth noting this titbit at the UITableView level:

It is also used for managing the “extra” separators drawn at the bottom of plain style tables.

I ran into a case where we wanted to try making the left-hand inset zero, so the separator lines stretch across the full width of the table, much like iOS 6 and before. Alright, configure .separatorInset of those cells to be UIEdgeInsetsZero, and voila! It, er, doesn’t quite work.

Despite setting to zero, there’s still a gap of about 8pt left on the left-hand side. What’s going on here? As ever a good first step is a quick Google search, and that tends to lead you to this Stack Overflow question.

Unfortunately, as is often the case for Stack Overflow, the existing answers didn't show too much understanding of the problem, and contain varying amounts of voodoo. So I took it upon myself to write a better answer. Have at it!

© Mike Abdullah 2007-2015