去掉底部tableView多余的表格线

  • 在用tableView时项目有个要求就是没有数据时不显示cell分割线
    代码如下很方便
[self.tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, kScreenWidth - 145);
  • 然后自带的cell分割线长度不够怎么解决呢?
  • 通过设置系统的属性也能达到这个目的:(弊端,只支持iOS8.0)
    设置tableView的separatorInset和cell的layoutMargins:
    self.tableView.separatorInset = UIEdgeInsetsZero;    
    cell.layoutMargins = UIEdgeInsetsZero;

重写cell的setFrame方法(万能):

 - (void)setFrame:(CGRect)frame {
        frame.size.height -= 5;       //  height减小的值就是分隔线的高度
        [super setFrame:frame];
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容