cell分割线左对齐,不起作用?用下边的方法

来源:互联网 发布:淘宝网丝绒长裙 编辑:程序博客网 时间:2024/05/21 04:25


http://www.skyfox.org/ios7-tableview-separatorinset-ajust.html

ios7下



//ios8下的新方法

-(void)viewDidLayoutSubviews

{

    if ([_iCoureseTabelViewrespondsToSelector:@selector(setSeparatorInset:)]) {

        [_iCoureseTabelViewsetSeparatorInset:UIEdgeInsetsZero];

        

    }

    if ([_iCoureseTabelViewrespondsToSelector:@selector(setLayoutMargins:)])  {

        [_iCoureseTabelViewsetLayoutMargins:UIEdgeInsetsZero];

    }

}

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{

    

    if ([cellrespondsToSelector:@selector(setLayoutMargins:)]) {

        [cell setLayoutMargins:UIEdgeInsetsZero];

    }

    if ([cellrespondsToSelector:@selector(setSeparatorInset:)]){

        [cell setSeparatorInset:UIEdgeInsetsZero];

    }

}


另外一种方法是

在cell init方法里加 


        if ([self respondsToSelector:@selector(setLayoutMargins:)])
        {
            self.preservesSuperviewLayoutMargins = NO;
            self.layoutMargins = UIEdgeInsetsZero;
        }
        if ([self respondsToSelector:@selector(setSeparatorInset:)])
        {
            self.separatorInset = UIEdgeInsetsZero;
        }

0 0
原创粉丝点击