Although there a few answers already on this topic. None of them cover Swift 3 and they are from a long time ago. What is currently the best way to change the separator heig
This is a correct way to do this.
First, in your ViewController you should set (tableView.separatorStyle = .none)
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.separatorStyle = .none
}
}
Second, in your TableViewCell class your should create a separatorView. And don't forget to inherit TableViewCell class for your cell.
class TableViewCell: UITableViewCell {
override func layoutSubviews() {
super.layoutSubviews()
//Your separatorLineHeight with scalefactor
let separatorLineHeight: CGFloat = 1/UIScreen.main.scale
let separator = UIView()
separator.frame = CGRect(x: self.frame.origin.x,
y: self.frame.size.height - separatorLineHeight,
width: self.frame.size.width,
height: separatorLineHeight)
separator.backgroundColor = .black
self.addSubview(separator)
}
}
Finally, you've got a thin separator line and, of course, you can increase this value what do you like.