美文网首页
iOS10 下移除UITableView Group第一行sec

iOS10 下移除UITableView Group第一行sec

作者: airron | 来源:发表于2018-05-31 09:57 被阅读42次
- (void)viewWillAppear:(BOOL)animated{
    CGRect frame = self.tableView.tableHeaderView.frame;
    frame.size.height = 1;
    UIView *headerView = [[UIView alloc] initWithFrame:frame];
    [self.tableView setTableHeaderView:headerView];
}

如果其他section 的header高度不需要调整则不需要实现以下协议

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 

如果其他section的header高度需要作出调整,则第一行section 的header高度一定要区别对待。例如:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    if (section == 0) {
        return CGFLOAT_MIN;
    }
    return 24.0;
}

除了第一section外其他section header高度都设置为24,第一行返回为 CGFLOAT_MIN 否则,第一行section header高度又会被重置为设置的高度。

参考:https://stackoverflow.com/questions/17699831/how-to-change-height-of-grouped-uitableview-header

相关文章

网友评论

      本文标题:iOS10 下移除UITableView Group第一行sec

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