0

I am using a UITableView where i need to remove the separator between first cell and HeaderView of a UITableView. Tried a some solution but nothing worked for me. Any kind of help will be appreciable. attaching screen shot of my current view and expected view My current view image My Expected view

Md. Sulayman
  • 781
  • 8
  • 30

2 Answers2

1

Separators are set per tableView, so it's not exactly possible to remove them just per cell.

However, if you set the tableview.separatorStyle = .none, and create a fake separator as a view in your cell at the bottom of the cell, you can achieve the look you're after.

Adis
  • 4,512
  • 2
  • 33
  • 40
0

You can use the following code:

Swift :

if indexPath.row == {your row number} {
    cell.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: .greatestFiniteMagnitude)
}

or :

cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, UIScreen.main.bounds.width)

for default Margin:

cell.separatorInset = UIEdgeInsetsMake(0, tCell.layoutMargins.left, 0, 0)

to show separator end-to-end

cell.separatorInset = .zero

Objective-C:

if (indexPath.row == {your row number}) {
    cell.separatorInset = UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, CGFLOAT_MAX);
}
Red Heart
  • 41
  • 1
  • 11