iOS UITableViewCell的分割线向左延长15(cell长度为全宽)

iOS7情况下:

  tableView.separatorInset = UIEdgeInsetsZero;
iOS8、9情况下:

首先在viewDidLoad方法中加上如下代码:
    if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [tableView setSeparatorInset: UIEdgeInsetsZero];
    }
    if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [tableView setLayoutMargins: UIEdgeInsetsZero];
    }
然后再加上这个方法:
  - (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];
    }
}
原文地址:https://www.cnblogs.com/ios988/p/6074409.html