iOS

  • 取消分隔线代码属于tableview的属性设置如下
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  • 分割线不对齐左侧默认留出15点空白,对齐设置代码:
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
{
     [self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])
 {
     [self.tableView setLayoutMargins:UIEdgeInsetsZero];
}

//然后在UITableView的代理方法中加入以下代码
- (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];
       }
}
  • 不对齐设置方法二:
self.tableView.separatorInset = UIEdgeInsetsMake(0, 100, 0, 0);
  • 如图:
原文地址:https://www.cnblogs.com/adampei-bobo/p/7059430.html