iOS tableviewcell 分割线不完整

在使用tableview的时候 发现cell之间的分割线与屏幕右边有一段小小的距离,如图:

屏幕快照 2016-09-07 下午2.02.45.png
  • 而如果想要让分割线从头开始,可以使用下面的方法,在tableview初始化的时候用下面这个方法

  • 代码如下:

    + (void)lineBeginWith:(UITableView *)tableview{
     if  (IOS_VERSION >= 8.0){
     if ([tableview respondsToSelector:@selector(setSeparatorInset:)]){
     [tableview setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([tableview respondsToSelector:@selector(setLayoutMargins:)]) {
     [tableview setLayoutMargins:UIEdgeInsetsZero];
            }  
        }
    }
    
  • 之后在对cell用下面这个方法

  • 代码如下:

    + (void)lineBeginWithCell:(UITableViewCell *)cell{
    if  (IOS_VERSION >= 8.0){
     if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
    [cell setSeparatorInset:UIEdgeInsetsZero];   
        }
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
            }
        }
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1、禁止手机睡眠[UIApplication sharedApplication].idleTimerDisabl...
    DingGa阅读 1,150评论 1 6
  • 版权声明:未经本人允许,禁止转载. iOS 7之后,tableView的分割线左边距默认设置为15,如图 iOS ...
    萧雪痕阅读 4,333评论 0 6
  • 1.XCode8的项目在xcode7运行报错: The document “ViewController.xib”...
    请叫我周小帅阅读 3,280评论 0 1
  • 夏日的午后有了几分慵懒和焦躁,可能多数是因为天气的原因,把孩子哄睡之后我也便恢复了自由,想写点什么来犒劳一下自己的...
    蜗牛的眼镜阅读 677评论 0 3
  • 重读金庸先生名著《笑傲江湖》有感,记之。 一入尘事皆是非 喜乐忧愁己欲追 凤求凰时两情悦 合鸣箫瑟自在飞 枭雄豪杰...
    天堂里没有痛阅读 496评论 6 26