swift3.0 tableviewcell分割線顯示不全解決方案
阿新 • • 發佈:2018-12-31
在viewDidLoad()新增一下程式碼
if tableView.responds(to:#selector(setter: UITableViewCell.separatorInset)) {
tableView.separatorInset = UIEdgeInsets.zero
}
if tableView.responds(to:#selector(setter: UIView.layoutMargins)) {
tableView.layoutMargins = UIEdgeInsets.zero
}
tableview實現多以下代理
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if cell.responds(to:#selector(setter: UIView.layoutMargins)) {
cell.layoutMargins = UIEdgeInsets.zero
}
if cell.responds(to: #selector(setter: UITableViewCell.separatorInset)) {
cell.separatorInset = UIEdgeInsets.zero
}
}