Home > OS >  Separator line UITableView
Separator line UITableView

Time:09-17

I have this table view but the separator line looks like double line

enter image description here

In the storyboard I have this settings (table view):

  • Style: Plain
  • Separator: None

This is my code:

class ListTableViewCell: UITableViewCell {
    
    @IBOutlet weak var transactionList: ransactionList!
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        let separator = UIView(frame: CGRect(x: 8, y: bounds.size.height - 0.5, width: bounds.size.width - 22, height: 1))
        separator.backgroundColor = UIColor.blue
        contentView.addSubview(separator)
    }

}

I expected something like this: enter image description here

CodePudding user response:

Here is how I made my own seperator line in the UITableViewDataSourceDelegate method.

//Separator Full Line
        cell.preservesSuperviewLayoutMargins = false
        cell.separatorInset = .zero
        cell.layoutMargins = .zero

I believe I also had

separatorStyle="default"

on the tableview

  • Related