21、[ iOS ] UITableViewCell 的分割线向

作者: 天听云道 | 来源:发表于2016-02-25 20:11 被阅读305次

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];
    }
}

相关文章

网友评论

  • leeyyl:找了很久终于找到了

本文标题:21、[ iOS ] UITableViewCell 的分割线向

本文链接:https://www.haomeiwen.com/subject/iuaikttx.html