iOS TableView分割线左面少一截问题

项目中遇到的一个问题,以前自己学习的时候,并没发现还有这个有趣的东西,只是在UI的设计图中,发现了这个。需求是这样的:

修改后.png

而我开始写出来是这样的:

修改前.png

不多说了 直接上代码。

    #pragma mark - <UITableViewDelegate>
     //处理tableview背景色和cell边界线
      - (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath
  {

cell.accessoryType = UITableViewCellAccessoryNone;
cell.backgroundColor = [UIColor clearColor];
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];

if ([cell respondsToSelector:@selector(setSeparatorInset:)])
{
    [cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)])
{
    [cell setPreservesSuperviewLayoutMargins:NO];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)])
{
    [cell setLayoutMargins:UIEdgeInsetsZero];
}
}

至于这个什么原因,大家可以自行去寻找,我就不解释了;嘻嘻

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

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,019评论 25 708
  • 今天早上到医院做身体检查,一大早迷迷糊糊六点多醒来,洗漱好以后就直接出门坐公交了。 再两站就是医院了,我心想:今天...
    小万管家阅读 712评论 3 6
  • 姓名:母光艳 公司:宁波贞观电器 第235期,利他二组 【日精进打卡第36天】 【知-学习】 读诵《六项精进》大纲...
    母光焱阅读 185评论 0 0