cell分割线不顶格

在- (void)viewDidLoad {}里面添加如下代码

if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {

[self.tableView setSeparatorInset:UIEdgeInsetsZero];

}

if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {

[self.tableView setLayoutMargins:UIEdgeInsetsZero];

}

随后添加tableview的代理方法

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

if ([cell respondsToSelector:@selector(setSeparatorInset:)]){

[cell setSeparatorInset:UIEdgeInsetsZero];

 }

if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {

[cell setLayoutMargins:UIEdgeInsetsZero];

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 版权声明:未经本人允许,禁止转载. iOS 7之后,tableView的分割线左边距默认设置为15,如图 iOS ...
    萧雪痕阅读 4,330评论 0 6
  • 1、禁止手机睡眠[UIApplication sharedApplication].idleTimerDisabl...
    DingGa阅读 1,144评论 1 6
  • 1. 打印View所有子视图 po [[self view]recursiveDescription] 2. la...
    Hurricane_4283阅读 1,002评论 0 2
  • 高三的生活其实很平淡但很充实,虽然紧张但并没有到了要死要活的地步!可是我们总爱装一下,明明不累却说好累,熬不下去了...
    萌耳与可阅读 256评论 0 1
  • 小莫儿 今天妈妈一早要出门,你一个人在家,自己起床吃早饭,然后写作业。虽然对于一个十二岁的孩子,这也算正常。但是妈...
    晶莹晶莹阅读 134评论 1 1