Hello guys Leo here. Today we will talk about UITableViewCells separator and how you can make them go all the width of the screen.

By default, Apple does the separator to be just a guideline to our eyes, and not literally a separator to all the content. This way the aesthetics of it is not going all the way to the end of the cell but just give the impression that things are separated. The design is brilliant while maintaining

Today will be a quick tip because of  “no time” constraints. And the reason for the image it’s because is a table… got it?

Let’s go.



First, let’s check in theory what is a table view cell.

If you're a mid/senior iOS developer looking to improve your skills and salary level, join this 100% free online crash course. It's available only until July 28th, so click to get it now!

A UITableViewCell object is a specialized sort of view that oversees the content of a single table row. You utilize cells basically to organize and display your app’s custom content, but UITableViewCell gives a few particular customizations to bolster table-related behaviors, including applying a determination or highlighting color to the cell, adding standard extra views, such as a detail or disclosure control, putting the cell into an editable state and indenting the cell’s content to form a visual progression in your table.

Your app’s content possesses most of the cell’s bounds, but the cell may adjust that space to form room for other content. Cells show extra views on the trailing edge of their content region. Once you put your table into edit mode, the cell includes a erase control to the driving edge of its substance zone and alternatively swaps out an accessory see for a reorder control.


Problem – UITableViewCells separator

You want the UITableViewCell separator go all width of the screen.

You can notice that the default insets for UITableViewCells start a little way from the left edge of the screen.

But you can make it start from the beginning just by adding this to your UITableView object:

myTableView.layoutMargins = UIEdgeInsets.zero
myTableView.separatorInset = UIEdgeInsets.zero


Adjusting the cell

And also add this to your *cellForRowAt* :

cell.layoutMargins = UIEdgeInsets.zero

And we are done!


Summary – Making UITableViewCells separator go all the screen width in Swift

Today you learned about UITableViewCells and how to make the separator view go all the way instead of being half drawn on the screen.

That’s all my people, I hope you liked reading this article as much as I enjoyed writing it. If you want to support this blog you can Buy Me a Coffee or leave a comment saying hello. You can also sponsor posts and I’m open to freelance writing! You can reach me on LinkedIn or Twitter and send me an e-mail through the contact page.

Thanks for the reading and… That’s all folks.

Credits – image