美文网首页别人的iOS精华
TableView cell 分割线顶头

TableView cell 分割线顶头

作者: 0x00chen | 来源:发表于2016-08-12 14:24 被阅读24次

不用这么麻烦了,在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 中加这两句代码就OK了。

    [cell setLayoutMargins:UIEdgeInsetsZero];
    [cell setSeparatorInset:UIEdgeInsetsZero];



-(void)viewDidLayoutSubviews{
    
    [super viewDidLayoutSubviews];
    if ([_tableVIew respondsToSelector:@selector(setSeparatorInset:)]) {
        [_tableVIew setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([_tableVIew respondsToSelector:@selector(setLayoutMargins:)]) {
        [_tableVIew setLayoutMargins:UIEdgeInsetsZero];
    }
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
        
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}


xiixixi

相关文章

网友评论

    本文标题:TableView cell 分割线顶头

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