开发者社区> 问答> 正文

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

- (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;
    }
}

screenshot

展开
收起
a123456678 2016-07-27 11:00:03 1827 0
1 条回答
写回答
取消 提交回答
  •  UIEdgeInsets contentInset = tableView.contentInset;
     contentInset.top = 0;
     [tableView setContentInset:contentInset];
    2019-07-17 20:00:25
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载