Grouped UITableview remove outer separator line

serhat sezer picture serhat sezer · Mar 12, 2015 · Viewed 41.1k times · Source

I have a grouped UITableview which is created programatically. Also I have a cell with xib file populated in tableview programmatically as well. So far so good. But I want to only remove outer separator line. I used below code but this time removed all separator line.

self.tableView.separatorColor = [UIColor clearColor];

this is not good option for my situation. Here is the screenshot what i want to do;

enter image description here

Answer

morizotter picture morizotter · Jun 14, 2016

You can remove separators even in grouped UITableView with Static Cell:

class CustomCell: UITableViewCell {

override func layoutSubviews() {
    super.layoutSubviews()
    for view in subviews where view != contentView {
        view.removeFromSuperview()
    }
}