美文网首页
UITableViewCell 分割线左侧间隔设置为0

UITableViewCell 分割线左侧间隔设置为0

作者: yangli | 来源:发表于2018-08-30 10:04 被阅读0次
//增加以下代理方法
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    //iOS7 添加属性separatorInset,设置为UIEdgeInsetsZero即可左对齐
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    //iOS8 之后,由于view添加属性layoutMargins,所以需要两个属性都设置为 UIEdgeInsetsZero
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

相关文章

网友评论

      本文标题:UITableViewCell 分割线左侧间隔设置为0

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