iOS tableViewCell plane格式下,接近section边缘不显示分割线却被复用解决方法

iOS tableViewCell plane格式下,接近section边缘不显示分割线却被复用解决办法

    今天做公司产品的时候遇到了如题问题,困扰我很长时间,用尽各种办法不能解决,究其原因不知为何,自定义cell低端有view划线的时候,划线一般的显示1像素,而贴着section的显示很少 顶多0.3像素,这个问题很头疼,后来 想到了一个非常好的办法解决:

 UIImageView *separatorLine = [[UIImageView alloc] initWithFrame:CGRectMake(20.0f*SizeScaleX, 30*SizeScaleY - 1.0f, cell.frame.size.width, 1.0f)];

        separatorLine.image = [[UIImage imageNamed:@"所有背景.png"] stretchableImageWithLeftCapWidth:1 topCapHeight:0];

        separatorLine.tag = 5554;

        

        [cell.contentView addSubview:separatorLine];

再做判断

 if(indexPath.row == arr.count-1){

        UIImageView *separatorLine = (UIImageView *)[cell viewWithTag:5554];

        separatorLine.hidden = YES;

    }else{

        UIImageView *separatorLine = (UIImageView *)[cell viewWithTag:5554];


        separatorLine.hidden = NO;


    }