美文网首页
TableViewCell分割线设置

TableViewCell分割线设置

作者: 旧时凉梦已成风 | 来源:发表于2019-03-11 10:27 被阅读0次

1.对齐两边分割线:

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

    }

}

2.取消多余的分割线:将足视图设为0frame

tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

相关文章

网友评论

      本文标题:TableViewCell分割线设置

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