首页 > 分组表视图顶部空白高度怎么调整

分组表视图顶部空白高度怎么调整

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

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (section == 0) {
        return 0;
    }else
        return 30;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return nil;
    }else {
        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 30)];
        headerView.backgroundColor = [UIColor whiteColor];

        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 30)];
        [label setText:@"    药品名称       单价         数量     总价   "];
        [headerView addSubview:label];
        return headerView;
    }
}


如图和代码,在section0的上面一段空缺灰色的,不知道怎么调整其高度。


看看
http://stackoverflow.com/questions/17699831/how-to-change-height-of-grouped-uitableview-header
多google就好了


 UIEdgeInsets contentInset = tableView.contentInset;
 contentInset.top = 0;
 [tableView setContentInset:contentInset];
【热门文章】
【热门文章】