227

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?

Tricky
  • 7,025
  • 5
  • 33
  • 43

9 Answers9

455

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
Kevin ABRIOUX
  • 16,507
  • 12
  • 93
  • 99
Bart Jacobs
  • 9,022
  • 7
  • 47
  • 88
  • 40
    You can also do this in IB, by the way (separator => none). – Bart Jacobs May 29 '09 at 09:56
  • 1
    This only seems to remove the separator lines within a table section. Is there a way to remove the separator lines *between* sections? – devios1 Jul 26 '13 at 23:00
  • 4
    The line between sections is not really a line, but the view of the section. You can change the view by implementing `tableView:viewForHeaderInSection:` from the `UITableViewDelegate` protocol. – Bart Jacobs Jul 27 '13 at 07:48
64

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

enter image description here

Kevin DiTraglia
  • 25,746
  • 19
  • 92
  • 138
62
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
}
Jonathan.
  • 53,997
  • 54
  • 186
  • 290
imthi
  • 4,798
  • 1
  • 22
  • 24
18

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];
Sig Myers
  • 371
  • 3
  • 13
  • This worked for me. In my case, the separator line was not actually appearing between cells, but actually somewhere in the middle of them. – Elliot Mar 07 '15 at 00:24
10

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()

Mohsin Qureshi
  • 1,203
  • 2
  • 16
  • 26
9

In Swift:

tableView.separatorStyle = .None
Mohsen
  • 64,437
  • 34
  • 159
  • 186
5

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];
Ky -
  • 30,724
  • 51
  • 192
  • 308
Siddhesh Mahadeshwar
  • 1,591
  • 14
  • 16
2

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

tableViews.separatorStyle = UITableViewCellSeparatorStyleNone;

This is working Code.

Ashu
  • 3,373
  • 38
  • 34
1

In your viewDidLoad:

self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
{
    [self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
Hilton Campbell
  • 6,065
  • 3
  • 47
  • 79
Aatish Javiya
  • 71
  • 1
  • 1