Sometimes we would want to have a “cleaner” UITableView

Removing extra cell lines in a UITableView

Using Swift 5!

George Garcia
2 min readApr 25, 2020

--

In this quick & short article, I will show you how to remove those extra lines, or you could say those “extra UITableViewCells”, from your UITableView. Keep in mind, this totally depends on how you like to design your Table View. So then, let’s proceed!

1. Creating an Extension

I find that creating extensions in our code base just helps a ton since it has the ability to have a better and organized code base and that you can extend functionalities to an existing class. Therefore, create a new file, for now I am calling it: “UITableView+Ext” or just name it whatever you want, and add these few lines of code.

Simple right?

2. Putting it into action

I am going to assume that you know how to setup a UITableView (with it’s delegate and dataSource protocols). So by creating a function, we can the add the logic to configure the table view.

Function called at Line 21

3. And that’s it!

Just in case, here are some images for visual examples and the code snippets for you “copy & pasters” 😉

Light and Dark Mode Differences
https://gist.github.com/georrgee/778ba9c5fafb5980cca31f62826b41bc
https://gist.github.com/georrgee/07c298cb2f42a19dc45a668ead3b4252

I hope that helps you out with your current or future projects! Thank you so much for your time into reading this article! 😁

Happy Coding!

--

--

George Garcia

Down to earth software engineer who’s passionate in mobile development