1.看了下官方文档
2.文档简介
See also UIEdgeInsetsMake(_:_:_:_:)
and UIEdgeInsetsZero
. 这个也可用 OC的
实力属性
类属性 static var zero: UIEdgeInsets
//下划线长度控制
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if cell.responds(to: #selector(setter: UIView.layoutMargins)) {
//cell.layoutMargins = UIEdgeInsetsMake(0, 50, 0, 0)
cell.layoutMargins = UIEdgeInsets(top: 0, left: 50, bottom: 0, right: 0)
cell.layoutMargins = UIEdgeInsets.zero
}
if cell.responds(to: #selector(setter: UITableViewCell.separatorInset)) {
cell.separatorInset = UIEdgeInsetsMake(0, 50, 0, 0)
//cell.separatorInset = UIEdgeInsets(top: 0, left: 50, bottom: 0, right: 0)
cell.separatorInset = UIEdgeInsets.zero
}
}