override func viewDidLoad() {

super.viewDidLoad()

// Do any additional setup after loading the view, typically from a nib.

// tableview顶部空白

self.automaticallyAdjustsScrollViewInsets = false

tableView = UITableView(frame: CGRectMake(10, 64, UIScreen.mainScreen().bounds.width - 20, 200), style: .Grouped)

tableView.delegate = self

tableView.dataSource = self

tableView.scrollEnabled = false

//        tableView.separatorStyle = .None

// tableview设置边框

// 设置边框的宽度

tableView.layer.borderWidth = 1

// 设置边框的颜色

tableView.layer.borderColor = UIColor.whiteColor().CGColor

// 设置UIView的边框为圆角和展现

tableView.layer.cornerRadius = 10

tableView.layer.masksToBounds = true

// 底部分割线左对齐

tableView.separatorInset = UIEdgeInsetsZero

tableView.layoutMargins = UIEdgeInsetsZero

tableView.cellLayoutMarginsFollowReadableWidth = false

self.view.addSubview(tableView)

}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCellWithIdentifier("cell") ?? UITableViewCell(style: .Default, reuseIdentifier: "cell")

cell.separatorInset = UIEdgeInsetsZero

cell.layoutMargins = UIEdgeInsetsZero

cell.preservesSuperviewLayoutMargins = false

return cell

}

PS:有时候只设置tableView和cell的SeparatorInsert和LayoutMargins仍然不能解决这个问题,左边一点距离始终没有办法封闭。
这时需要设置tableView的cellLayoutMarginsFollowReadableWidth,和cell的preservesSuperviewLayoutMargins。

转载于:https://www.cnblogs.com/gongyuhonglou/p/10311558.html

Swift - UITableView里的cell底部分割线左侧靠边相关推荐

  1. Swift - UITableView状态切换效果

    Swift - UITableView状态切换效果 效果 源码 https://github.com/YouXianMing/Swift-Animations // // TableViewTapAn ...

  2. 【SeeMusic】视频编辑 ( 顶部裁剪 | 底部裁剪 | 左侧裁剪 | 右侧裁剪 | 明亮度 | 对比度 | 色调 | 饱和度 )

    SeeMusic 系列文章目录 [SeeMusic]下载安装并注册 SeeMusic 软件 [SeeMusic]创建 SeeMusic 工程并编辑相关内容 ( 创建工程 | 导入 MIDI 文件 | ...

  3. 动态改变UITableView中的Cell高度

    往往在开发iPhone的应用过程中用得最多的应该算是UITableVIew了,凭着IOS给UITableView赋予了这种灵活的框架结构,让它不管在显示列表方面还是在排版方面都有着一定的优势.虽然UI ...

  4. UITableView移除某一行cell的分割线

    为什么80%的码农都做不了架构师?>>>    以前一直以为不能单独去掉cell的一行分割线,所以处理特殊的UI时,甚至用嵌套UITableView,最终导致处理逻辑变得相对复杂了: ...

  5. iOS swift UITableView的cell被点击或是用代码选中其中的UIImageView会显示Highlighted效果

    文章目录 1.展示 2.cell的代码选中不能用cell.isSelected,而要用tableView.selectRow( 1.展示 2.cell的代码选中不能用cell.isSelected,而 ...

  6. Swift - UITableView

    创建UITablView import UIKitclass ViewController: UIViewController,UITableViewDataSource,UITableViewDel ...

  7. UI:UITableView 编辑、cell重用机制

    tableView编辑.tableView移动.UITableViewController tableView的编辑:cell的添加.删除. 使⽤场景: 删除⼀个下载好的视频,删除联系⼈: 插⼊⼀条新 ...

  8. iOS开发之高级视图—— UITableView(四)自定义Cell

    当我们使用UITableView的时候,经常需要自定义Cell,这个例子展示了一个简单的自定义的Cell. HeroViewCell.h // // HeroViewCell.h // ExtendC ...

  9. UITableView(UIScrollView)滑动到底部的判断

    公司要求增加一个埋点,那就是在一个UITableView滚动到底部的时候,增加一个统计事件,证明这个人的资料被完整的读完了. 先说一下UIScrollView的常用属性 - (void)scrollV ...

最新文章

  1. leangoo领歌敏捷工具工作台可查看最近访问脑图和项目
  2. R语言NaN函数实战(计数、替换、删除)
  3. Ubuntu14.04 + Text-Detection-with-FRCN(CPU)
  4. 中国最大AI芯片发布,顺手拿下四个国内第一,带Benchmark的那种
  5. excel 多项式拟合数据
  6. CentOS 初体验七:常用命令
  7. iphone屏蔽系统更新_屏蔽 iOS 系统更新的最新方法,支持所有 iPhone、iPad 设备
  8. RPC(远程过程调用)原理及应用
  9. python round_python round()
  10. 微软应用商店下载应用教程(附带power shell命令)
  11. python代码解读_python源代码解读
  12. iNet Network Scanner Mac(网络扫描工具)
  13. PostgreSQL客户端认证配置
  14. java int转byte数组
  15. 45分布式电商项目 - SpringDataSolr 入门例子
  16. 工业相机快门类型:卷帘快门和全局快门——哪个最好?
  17. android 视频上传网络异常,App上传视频(或大文件)失败怎么办?
  18. 跨境电商供应链难点有哪些?
  19. ultron官网,奥创官网,奥创中国区官网,ultron中国区官网,奥创公链,ultron公链,ulx,ultron奥创,ultron,奥创,海洋renhe333333
  20. Java 在线编程编译工具上线,直接运行Java代码

热门文章

  1. [INS-20802] Oracle Net Configuration Assistant failed
  2. Drupal basic
  3. java—IO流——读取键盘输入的字母并转换成大写字母输出在控制台上
  4. 项目发布Debug和Release版的区别
  5. 网际控制报文协议---ICMP
  6. [Groovy] How to check if element in groovy array/hash/collection/list?
  7. jQuery 学习笔记之十二 (选项卡)
  8. 亲,如果你笑了,记住给我留言!
  9. [转]聚集索引和非聚集索引(sql server索引结构及其使用)
  10. setState的异步,同步以及合并