Making UITableViewCells separator go all the screen width in Swift

Subscribe to my newsletter and never miss my upcoming articles

Hello guys Leo here,

Today will be a quick tip because "no time" constraints. And the reason for the imagem it's because is a table... got it?

Let's go.

Problem

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 adding this to your UITableView object:

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

And also add this to your cellForRowAt :

cell.layoutMargins = UIEdgeInsets.zero

Done!

Any thoughts or comments please share below.

Thanks for the reading and... That's all folks!

Credits: image

No Comments Yet