2

iOS , how can I set the separator line style is none for only one cell ,for others the separator is default?

I just want to remove the separator line for the section 2,row 3 cell. And for all others ,there still exist separator line.

I know a way is to set self.tableview.separator=NONE, and for the cells who want separator just add subview. But I do not think it is a optimal way.

After use

cell.separatorInset = UIEdgeInsetsMake(0.f, 0.f, 0.f, self.view.frame.size.width);

Still remain… enter image description here

there is about 15px width I suppose..

seguedestination
  • 419
  • 4
  • 19
  • possible duplicate of [hide separator line on one UITableViewCell](http://stackoverflow.com/questions/8561774/hide-separator-line-on-one-uitableviewcell) – Anbu.Karthik Jun 24 '15 at 06:37

2 Answers2

0

simply check indexPath in cellForRow method, if it's indexPath.section == 1 then set separator.hidden = NO

Nicholas Ng
  • 1,428
  • 18
  • 23
0

You can set the separatorInset:

if (indexPath.row == {your row number}) {
    // hide the line
    cell.separatorInset = UIEdgeInsetsMake(0.f, 0.f, 0.f, cell.bounds.size.width);
} else {
    // show the line
    cell.separatorInset = UIEdgeInsetsMake(0.f, 15.f, 0.f, 0.f);
}
Bannings
  • 10,376
  • 7
  • 44
  • 54