美文网首页
cell中间的分割线左边没有短缺,标题距左边有一定的距离

cell中间的分割线左边没有短缺,标题距左边有一定的距离

作者: 闲云悠鹤蝶恋舞 | 来源:发表于2016-05-01 20:56 被阅读49次
    cell中间的分割线左边没有短缺,标题距左边有一定的距离
    如下图:
    Paste_Image.png
    解决方法如下:
    • 注意:只需要写下面的两个方法即可
    步骤一:
    -(void)viewDidLayoutSubviews {
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
            [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 10, 0, 0)];   
        }
        if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])  {
            [self.tableView setLayoutMargins:UIEdgeInsetsZero];
        }
    }
    
    
    步骤二:
    -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPat{
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
            [cell setLayoutMargins:UIEdgeInsetsZero];
        }
        if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
            [cell setSeparatorInset:UIEdgeInsetsZero];
        }
    }
    
    

    相关文章

      网友评论

          本文标题:cell中间的分割线左边没有短缺,标题距左边有一定的距离

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