ios – 仅为一个单元格删除分隔线

前端之家收集整理的这篇文章主要介绍了ios – 仅为一个单元格删除分隔线前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图删除一个UITableViewCell的分隔符.我做了以下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell;
    cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];

    if (indexPath.row == 1)
        cell.separatorInset = UIEdgeInsetsZero;

    return cell;
}

(它是静态单元格)当我运行应用程序分隔线仍然在那里.如何删除一个单元格的分隔线

解决方法

在iOS 8上,您需要使用:
cell.layoutMargins = UIEdgeInsetsZero

如果您想要与iOS 7兼容,您应该执行以下操作:

if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
    [cell setSeparatorInset:UIEdgeInsetsZero];
}

if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
    [cell setLayoutMargins:UIEdgeInsetsZero];
}

添加:如果以前没有工作 – 使用这个. (从下面回答)

cell.separatorInset = UIEdgeInsetsMake(0,1000,0);
原文链接:https://www.f2er.com/iOS/337672.html

猜你在找的iOS相关文章