以往我们创建tableview 的时候用控件自带的分割线左边总会有10个像素左右的空隙,看网上的内容说什么xcode 右侧弹出勾选什么什么就好了的,其实并没有什么卵用
其实只要加上以下代码就好了
- (void)tableView:(UITableView *)tableView willDisplayCell:(nonnull UITableViewCell *)cell forRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
//设置separatorInset(iOS7之后)
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
}
效果图:
未加之前:
添加以后:
简单粗暴,亲测有用~!!