您的位置:首页 > 移动开发 > Swift

swift cell 分割线 显示不全 自由控制长度

2017-09-14 17:15 337 查看
1.看了下官方文档



2.文档简介

See also 
UIEdgeInsetsMake(_:_:_:_:)
 and 
UIEdgeInsetsZero
.    
这个也可用 OC的

实力属性

var bottom:
CGFloat

var left:
CGFloat

var right:
CGFloat

var top:
CGFloat


类属性
static var zero: UIEdgeInsets

3.具体代码 

//下划线长度控制
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
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: