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
Asked
Active
Viewed 119 times
0

Md. Sulayman
- 781
- 8
- 30
2 Answers
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
-
Tried that before. It remove the separator line between first and second cell. I need to remove separator between header and first cell – Md. Sulayman Mar 15 '19 at 04:16
-
you can try to hide in your header cell. – Red Heart Mar 15 '19 at 04:29
-
we don't have access to separator view, isn't it? – Md. Sulayman Mar 15 '19 at 04:57