如何更改分组 UITableView 标题的高度? [英] How to change height of grouped UITableView header?

查看:37
本文介绍了如何更改分组 UITableView 标题的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何更改表格视图中节标题的高度.但是我找不到任何解决方案来更改第一部分之前的默认间距.

I know how to change the height of the section headers in the table view. But I am unable to find any solution to change the default spacing before the first section.

现在我有这个代码:

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

推荐答案

看来我无法设置高度为 0 的表头视图.我最终做了以下事情:

It appears that I can't set a table header view with height of 0. I ended up doing the following:

- (void)viewWillAppear:(BOOL)animated{
    CGRect frame = self.tableView.tableHeaderView.frame;
    frame.size.height = 1;
    UIView *headerView = [[UIView alloc] initWithFrame:frame];
    [self.tableView setTableHeaderView:headerView];
}

这篇关于如何更改分组 UITableView 标题的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆