husharoonie
husharoonie

Reputation: 441

Remove single separator line from UITableViewCell

How can I only remove the top line separator from a tableView cell programatically.

For example:

//remove top line seperator from cell 0
if indexPath.row == 0 { 
   cell.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: .greatestFiniteMagnitude)
}

removes both separator lines for top and bottom. I want to just remove the seperator line from the top and NOT the bottom.

I have tried but dont work:

cell.separatorInset = UIEdgeInsets(top: .greatestFiniteMagnitude, left: 0, bottom: 0, right: 0)
cell.separatorInset.top = .greatestFiniteMagnitude

Upvotes: 0

Views: 75

Answers (1)

matt
matt

Reputation: 535139

The easiest way is: don't use built-in separator lines. Draw the line yourself (as part of the cell) in each row where you want one, and don't draw it (i.e. remove it) in each row where you don't want it.

Upvotes: 1

Related Questions