LgSus97
LgSus97

Reputation: 93

Separator line UITableView

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):

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

Upvotes: 1

Views: 734

Answers (1)

goatofanerd
goatofanerd

Reputation: 468

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

Upvotes: 1

Related Questions