mantov1
mantov1

Reputation: 117

iOS swift remove UITableView Cell separator space

i am trying to remove the tableView separator, i do that by setting the separator style to none, this removes the separator but leaves the space between the cells.

My question is how do i remove that space between the cells?

Any help would be appreciated.

Upvotes: 0

Views: 2550

Answers (2)

sylvanaar
sylvanaar

Reputation: 8216

I do it in cellForRowAtIndexPath

    // remove the spaces on the cell separators
    if (cell.respondsToSelector("setPreservesSuperviewLayoutMargins:")) {
        cell.preservesSuperviewLayoutMargins = false
    }
    cell.separatorInset = UIEdgeInsetsZero
    if(cell.respondsToSelector("setLayoutMargins:")){            
        cell.layoutMargins = UIEdgeInsetsZero
    }

Upvotes: -2

Özgür Ersil
Özgür Ersil

Reputation: 7013

In awakeFromNib function setting UITableViewCell options to UIEdgeInsetsZero should work

  self.layoutMargins = UIEdgeInsetsZero
  self.separatorInset = UIEdgeInsetsZero

Upvotes: 7

Related Questions