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。

Swift - UITableView里的cell底部分割线左侧靠边的更多相关文章

  1. xib连线出错,模型保存cell状态(最后个Cell隐藏分割线),

    一个.m文件中有好几个cell类,拖线,要看看该控件对应的是哪个类,否则点击事件不响应,因为归属的xib错了 拖不过来线,因为是view拖不动,加了个button就行了   使用模型属性记录是否隐藏c ...

  2. Swift - 实现点击cell动态修改高度

    Swift - 实现点击cell动态修改高度 效果 源码 https://github.com/YouXianMing/Swift-Animations // // TapCellAnimationC ...

  3. SWIFT UITableView的基本用法

    import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: ...

  4. Swift - UITableView状态切换效果

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

  5. UITableView中复用cell显示信息错乱

    UITableView继承自UIScrollview,是苹果为我们封装好的一个基于scroll的控件.上面主要是一个个的 UITableViewCell,可以让UITableViewCell响应一些点 ...

  6. Swift - UITableView展开缩放动画

    Swift - UITableView展开缩放动画 效果 源码 https://github.com/YouXianMing/Swift-Animations // // HeaderViewTapA ...

  7. iOS之UITableView中的cell因为重用机制导致新的cell的数据出现重复或者错乱

      UITableView中的cell可以有很多,一般会通过重用cell来达到节省内存的目的:通过为每个cell指定一个重用标识符(reuseIdentifier),即指定了单元格的种类,当cell滚 ...

  8. iOS中UITableView分割线左侧顶齐

    iOS 7开始UITableView的分割线不在从左侧边界开始了,而是默认空出了一段距离. 如果想要使用默认的分割线而且还要从左侧边界开始的话,有几种解决方式: 1.在tableView的代理方法中设 ...

  9. iOS UITableView中关于cell里的按钮被点击时如何确定是哪一个section

    在section=10:row=1:的UITableView中,每一个cell都带有一个按钮,例如如下的图片一样每一个cell中都有一个“进入店铺的按钮”,但是如果我点击相应的cell要进入对应的店铺 ...

随机推荐

  1. 【Beta版本】七天冲刺——日志集合贴

    No Bug 031402401鲍亮 031402402曹鑫杰 031402403常松 031402412林淋 031402418汪培侨 031402426许秋鑫 Day1 Day2 Day3 Day ...

  2. Thinking in java学习笔记之final

  3. hihoCoder 后缀数组 重复旋律

    #1403 : 后缀数组一·重复旋律 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为长度为 N 的数构成 ...

  4. noip2016十连测round1

    A:String Master 题目:所谓最长公共子串,比如串 A:"abcde",串 B:"jcdkl",则它们的最长公共子串为串 "cd" ...

  5. python 批量扫描mongodb 未授权访问脚本

    需要 pymongo库easy_install pymongo脚本: import socket import sys import pymongo ipcons = [] def Scanner(i ...

  6. wpf 客户端 添加qq客服咨询

    使用qq推广 站点:http://shang.qq.com/v3/widget.html 复制里面的html代码: <a target=" src="http://wpa.q ...

  7. RESTEasy-Rest服务框架

    什么是 RESTEasy RESTEasy 是 JBoss 的一个开源项目,提供各种框架帮助你构建 RESTful Web Services 和 RESTful Java 应用程序.它是 JAX-RS ...

  8. Spring中配置和读取多个Properties文件--转

    public class PropertiesFactoryBeanextends PropertiesLoaderSupportimplements FactoryBean, Initializin ...

  9. 【荐】PHP操作MongoDB GridFS 存储文件,如图片文件

    GridFS是MongoDB的一个内置功能,它提供一组文件操作的API以利用MongoDB存储文件,GridFS的基本原理是将文件保存在两个Collection中,一个保存文件索引,一个保存文件内容, ...

  10. PHP 的异常处理、错误处理:error_reporting,try-catch,trigger_error,set_error_handler,set_exception_handler,register_shutdown_function

    一.错误.异常 等级常量表 error:不能在编译期发现的运行期错误,比如试图用 echo 输出一个未赋值的变量,这类问题往往导致程序或逻辑无法继续下去而需要中断: exception:程序执行过程中 ...