Swift UITableViewCell 分割线从最左端开始
2017-08-16 22:56
239 查看
前言
系统默认的分割线距离最左端有一点距离,这是我们经常处理的一种情况是分割线到最左端,下面提供3种解决办法供大家参考方法1
此方法的实现略微复杂//在初始化tableview时,加上这两句 if tableView.responds(to:#selector(setter: UITableViewCell.separatorInset)) { tableView.separatorInset = .zero } if tableView.responds(to: #selector(setter: UITableViewCell.layoutMargins)) { tableView.layoutMargins = .zero } //...... //在代理中实现 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if cell.responds(to: #selector(setter: UITableViewCell.separatorInset)) { cell.separatorInset = .zero } if cell.responds(to: #selector(setter: UITableViewCell.layoutMargins)) { cell.layoutMargins = .zero } }
方法2
//在初始化tableView 时加上这一句即可 tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0) //或者 tableView.separatorInset = UIEdgeInsets.zero
方法3
//初始化tableView时隐藏掉系统的分割线 tableView.separatorStyle = .none //自定义tabelViewCell 在最底部加上一根分割线
相关文章推荐
- UITableView的分割线从最左侧开始, 右箭头,分割线颜色; UITableViewCell中ImageView位置大小控制
- UITableView的分割线从最左侧开始, 右箭头,分割线颜色; UITableViewCell中ImageView位置大小控制
- uitableviewcell底部分割线如何设为虚线
- 去掉/自定义 UITableViewCell分割线方法
- swift学习之UITabelView ----UITableViewCell
- iOS-UITableViewCell自定义分割线
- UITableViewCell的分割线不满屏的解决办法
- iOS-swift-tableview隐藏多余的cell分割线
- swift UITableViewCell插入单无格
- UITableView 分割线贴近左端屏幕开始
- iOS tabelView 分割线从最左边开始及隐藏多余的cell
- iOS-OC-UITableViewCell分割线自定义
- 自定义UITableViewCell分割线不显示或粗细不同的原因
- UITableViewCell 多余的分割线不显示
- 从头开始swift2.1 仿搜材通项目(十) 趋势图、Cell的重用及View的隐藏
- UITableViewCell 分割线左对齐
- UITableViewCell自定义分割线
- Swift UITableViewCell Set方法赋值
- uitableViewCell分割线满格 顶格
- Swift UITableViewCell点击展开