Remove UITableView separator line

I want to remove the line between 2 views. The line that separates 2 UITableViewCells:

enter image description here

I declared table view as following:

self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
self.tableView.scrollEnabled = NO;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.estimatedRowHeight = 85.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;

So i actually wrote - self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

Why does it still exist?


Objective-C :

[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

Swift:

self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None

Swift 5.0 renamed it in :

self.tableView.separatorStyle = UITableViewCell.SeparatorStyle.none

Apply the line in viewDidLoad() method.

If you want to do it from nib file, set the tableView's Separator property to None


For Swift 4:

tableView.separatorStyle = .none

For Swift 5 :

 viewDidLoad(){
     tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
    }

For Objective-C :

[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

or you can use interface builder instead

enter image description here


For more information

SeparatorStyle


Hide tableView separators using UI

Here you select TableView 'Separator' property as 'None'.

https://i.stack.imgur.com/8KyH5.png


You can use the following code because it will not remove the line separators of the sections.:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    // Your code here //

    cell.separatorInset = UIEdgeInsetsMake(0.f, [UIScreen mainScreen].bounds.size.width, 0.f, 0.f);

}