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

Objective CCocoa TouchUikit

Objective C Problem Overview


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?

Objective C Solutions


Solution 1 - Objective C

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

Solution 2 - Objective C

You can do this in the storyboard / xib editor as well. Just set Seperator to none.

enter image description here

Solution 3 - Objective C

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
}

Solution 4 - Objective C

I still had a dark grey line after attempting the other answers. I had to add the following two lines to make everything "invisible" in terms of row lines between cells.

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.separatorColor = [UIColor clearColor];

Solution 5 - Objective C

In interface Builder set table view separator "None"

enter image description here and those separator lines which are shown after the last cell can be remove by following approach. Best approach is to assign Empty View to tableView FooterView in viewDidLoad

self.tableView.tableFooterView = UIView()

Solution 6 - Objective C

In Swift:

tableView.separatorStyle = .None

Solution 7 - Objective C

There is bug a iOS 9 beta 4: the separator line appears between UITableViewCells even if you set separatorStyle to UITableViewCellSeparatorStyleNone from the storyboard. To get around this, you have to set it from code, because as of now there is a bug from storyboard. Hope they will fix it in future beta.

Here's the code to set it:

[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

Solution 8 - Objective C

In the ViewDidLoad Method, you have to write this line.

tableViews.separatorStyle = UITableViewCellSeparatorStyleNone;

This is working Code.

Solution 9 - Objective C

In your viewDidLoad:

self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
{
    [self.tableView setSeparatorInset:UIEdgeInsetsZero];
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTrickyView Question on Stackoverflow
Solution 1 - Objective CBart JacobsView Answer on Stackoverflow
Solution 2 - Objective CKevin DiTragliaView Answer on Stackoverflow
Solution 3 - Objective CimthiView Answer on Stackoverflow
Solution 4 - Objective CSig MyersView Answer on Stackoverflow
Solution 5 - Objective CMohsin QureshiView Answer on Stackoverflow
Solution 6 - Objective CMohsenView Answer on Stackoverflow
Solution 7 - Objective CSiddhesh MahadeshwarView Answer on Stackoverflow
Solution 8 - Objective CAshuView Answer on Stackoverflow
Solution 9 - Objective CAatish JaviyaView Answer on Stackoverflow