Programming

Is there a way to remove the separator line from a UITableView

19 September 2026 · 11 min read

Is there a way to remove the separator line from a UITableView

The UITableView is a fundamental UI element in iOS development, used extensively for displaying lists of data. However, developers often encounter the need to customize its appearance to align with specific app designs. One common customization request is: Is there a way to remove the separator line from a UITableView? These lines, while helpful for visual distinction by default, can sometimes clash with a cleaner or more minimalist aesthetic. Removing or customizing these separators can significantly enhance the visual appeal of your app. In this comprehensive guide, we’ll explore various methods to achieve this, from simple property adjustments to more advanced techniques involving custom cells and table view configurations. We will cover each approach in detail, providing code examples and best practices to ensure seamless integration into your iOS projects. Understanding these techniques allows for greater flexibility in UI design and a more polished user experience.

Understanding UITableView Separator Styles

Before diving into the methods for removing separator lines, it’s crucial to understand the different separator styles available for UITableView. By default, UITableView uses a separator style that displays lines between each cell, providing visual separation and improving readability. The separatorStyle property of UITableView controls this behavior. The available options include .singleLine, .none, and .singleLineEtched. Understanding these styles is the first step in customizing the separators to fit your application’s design. The default separatorStyle is .singleLine, which draws a thin line between each cell. Developers can easily change this style to .none to completely remove the separator lines. This is the most straightforward approach and often sufficient for achieving a clean look.

Furthermore, the separatorColor property allows you to customize the color of the separator lines if you choose to keep them visible but want to change their appearance. You can set this property to any UIColor value to match your app’s theme. For example, you might use a lighter shade of gray for a subtle separation or a vibrant color to make the separators stand out. Customizing the separator color, combined with adjusting the cell background color, provides a wide range of visual options without completely removing the separators. It’s important to consider the overall visual harmony of your app when making these adjustments. Experiment with different colors and styles to find the best fit for your design.

Beyond simple color changes, you can also customize the inset of the separator lines, controlling how far they extend from the left and right edges of the table view. This is achieved by setting the separatorInset property. The separatorInset property is a UIEdgeInsets value, allowing you to specify different insets for the top, left, bottom, and right sides of the separator. This gives you fine-grained control over the position and appearance of the separator lines. According to Apple’s Human Interface Guidelines, consistency is key to a good user experience, so ensure your separator styles and insets are consistent throughout your app. Apple’s Human Interface Guidelines provide valuable insights into designing user-friendly interfaces.

Method 1: Hiding Separators Using separatorStyle = .none

The simplest and most direct method to remove separator lines from a UITableView is by setting its separatorStyle property to .none. This approach completely hides the separator lines, providing a clean and minimalist look. This is especially useful when your cells have clear visual boundaries or when you prefer to use custom separators. To implement this, you can add the following line of code to your viewDidLoad() method or wherever you initialize your table view:

tableView.separatorStyle = .none 

This single line of code will remove all separator lines from your table view. It’s a quick and effective solution for achieving a clean look. However, keep in mind that removing separators entirely might make it harder for users to distinguish between cells, especially if the cell content doesn’t have clear visual boundaries. Therefore, consider the overall design and user experience when choosing this approach. If you find that removing separators makes the table view look too cluttered, you might want to explore alternative methods, such as custom separators or adjusting the cell background colors to provide better visual separation.

When using separatorStyle = .none, it’s important to ensure that your cells have sufficient visual distinction to prevent the content from appearing as a single, undifferentiated block. This can be achieved through the use of distinct background colors, borders, or spacing between cells. For example, you might set a subtle background color for each cell or add a small margin around the cell content to create visual separation. Consider the overall color scheme and design of your app when choosing these visual cues. A well-designed table view should be both visually appealing and easy to navigate, even without traditional separator lines. According to a study by Nielsen Norman Group, clear visual cues significantly improve usability and reduce user errors. Nielsen Norman Group - Visual Hierarchy.

Method 2: Customizing Separator Insets

If you prefer to keep the separator lines but want to customize their appearance, you can adjust their insets. The separatorInset property allows you to control the position of the separator lines relative to the edges of the table view. This is useful for creating a more refined look or for aligning the separators with specific elements within your cells. The separatorInset property is a UIEdgeInsets struct, which allows you to specify the top, left, bottom, and right insets. By adjusting these values, you can create various effects, such as indenting the separators or extending them beyond the cell boundaries.

For example, to indent the separator lines from the left edge of the table view, you can set the separatorInset property as follows:

tableView.separatorInset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 0) 

This code will indent the separator lines by 20 points from the left edge of the table view. You can adjust the left value to control the amount of indentation. Similarly, you can adjust the right value to indent the separators from the right edge. Customizing the separator insets allows you to create a more visually appealing and consistent look throughout your app. Experiment with different inset values to find the best fit for your design. Remember to consider the overall layout and design of your cells when adjusting the separator insets. The goal is to create a visually harmonious and easy-to-navigate table view. Learn more about custom UI elements.

It’s important to note that the separatorInset property affects all separator lines in the table view. If you need to customize the separator insets for individual cells, you’ll need to use a more advanced technique, such as creating custom separator views within each cell. This approach provides more granular control over the appearance of the separators but requires more code and effort. When deciding whether to use the separatorInset property or custom separator views, consider the complexity of your design and the level of customization required. If you only need to adjust the insets for all separators, the separatorInset property is the simplest and most efficient solution. However, if you need to customize the separators for individual cells, custom separator views are the way to go.

Method 3: Using Custom Separator Views

For more advanced customization, you can create custom separator views within each cell. This approach gives you complete control over the appearance and positioning of the separators. Instead of relying on the default separator lines provided by UITableView, you create your own views and add them to the bottom of each cell. This allows you to create separators with custom colors, thicknesses, and positions. This method is particularly useful when you need to create separators that are different from the default style or when you want to add separators that are not simple lines.

Here’s a general outline of the steps involved in creating custom separator views:

  1. Create a custom UITableViewCell subclass.
  2. In the init(style:reuseIdentifier:) method of your custom cell, create a UIView for the separator.
  3. Set the background color and frame of the separator view.
  4. Add the separator view as a subview of the cell’s contentView.
  5. Use Auto Layout constraints to position the separator view at the bottom of the cell.

This approach provides maximum flexibility in customizing the appearance of the separators. You can create separators with custom colors, thicknesses, and positions. You can even add shadows or gradients to the separators to create more visually interesting effects. However, this approach also requires more code and effort than simply setting the separatorStyle property to .none. When deciding whether to use custom separator views, consider the complexity of your design and the level of customization required. If you only need to remove the separators or adjust their insets, the simpler methods are likely sufficient. But if you need more advanced customization, custom separator views are the way to go.

  • Custom separator views offer the most flexibility.
  • Requires more code and careful Auto Layout setup.

For example, let’s say you want to create a separator that is a light gray line with a height of 1 point and is positioned at the very bottom of the cell. You would create a UIView, set its background color to light gray, set its height to 1 point, and then add it as a subview of the cell’s contentView. You would then use Auto Layout constraints to position the separator at the bottom of the cell, extending from the left edge to the right edge. This would create a custom separator that is visually distinct from the default separator lines provided by UITableView. Remember to consider the overall design and user experience when creating custom separators. The goal is to create separators that are both visually appealing and functional.

Method 4: Removing Separators for Empty Cells

Sometimes, you might want to remove the separator lines only for empty cells in your table view. This is often the case when you have a dynamic table view that displays a varying number of cells based on the data available. You don’t want to show separator lines for the empty cells at the bottom of the table view. This can be achieved by setting the tableFooterView property of the UITableView to an empty UIView. This effectively hides the separator lines for any empty cells that might be present below the last data-containing cell.

Here’s how you can implement this:

tableView.tableFooterView = UIView() 

This single line of code will remove the separator lines for any empty cells at the bottom of the table view. It’s a simple and effective solution for cleaning up the appearance of dynamic table views. This ensures that the table view looks clean and professional, even when there are no more data to display. This technique is particularly useful when you are fetching data from a remote server and the number of cells displayed in the table view can vary based on the response. It’s important to consider the overall design and user experience when implementing this technique. The goal is to create a table view that is both visually appealing and easy to navigate, even when there are empty cells present.

  • Useful for dynamic table views with varying numbers of cells.
  • Set tableFooterView to an empty UIView to hide extra separators.

It’s important to note that this technique only removes the separator lines for empty cells at the bottom of the table view. It does not affect the separator lines between the data-containing cells. If you want to remove the separator lines for all cells, you need to use one of the other methods described above, such as setting the separatorStyle property to .none. When deciding which method to use, consider the specific requirements of your design and the desired appearance of your table view. If you only want to remove the separator lines for empty cells, setting the tableFooterView property to an empty UIView is the simplest and most effective solution.

Featured Snippet Optimized: To remove separator lines from a UITableView, the quickest method is to set the separatorStyle property to .none. This simple code snippet, tableView.separatorStyle = .none, completely hides all separator lines, giving your table view a clean, minimalist look. This is especially useful when your cells already have distinct visual boundaries or when you prefer a cleaner aesthetic.

Infographic here
FAQ: Removing UITableView Separator Lines -----------------------------------------
Q: How do I completely remove separator lines from a UITableView?
A: Set the separatorStyle property of the UITableView to .none.
Q: Can I customize the color of the separator lines?
A: Yes, you can set the separatorColor property to any UIColor value.
Q: How do I adjust the position of the separator lines?
A: Use the separatorInset property to control the insets of the separator lines.
Q: How can I remove separator lines for empty cells only?
A: Set the tableFooterView property of the UITableView to an empty UIView.
Removing or customizing separator lines in a UITableView is **Question & Answer :**

I’m looking for a way to completely remove the separator line in a UITableView when in the plain mode. This is done automatically in grouped, but this also changes the dimensions of the table in a way that is hard to measure. I have set the seperator line color to colorClear. But this does not completely solve the problem.

As I am trying to draw a custom background view in the cells, and I want the cells to be seamless, the one pixel line that remains in-between is causing me problems. Is there a more elegant workaround then using a grouped view and then stretching it?

You can do this with the UITableView property separatorStyle. Make sure the property is set to UITableViewCellSeparatorStyleNone and you’re set.

Objective-C

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 

In Swift (prior to 3)

tableView.separatorStyle = .None 

In Swift 3/4/5

tableView.separatorStyle = .none