iOS-UITableView使用UITableViewStyleGrouped的section高度设置

  • sectionHeader使用此方法
- ( CGFloat )tableView:( UITableView *)tableView heightForHeaderInSection:( NSInteger )section
{
//对于section == 0 时返回0.01因为 不能返回0 返回0系统会返回自己的默认值
       return section == 0 ? 20 : 0.01;
}
  • sectionFooter这个方法无效
- ( float )tableView:( UITableView *)tableView heightForFooterInSection:( NSInteger )section{
       return 10.0;
} 

需要使用:self.tableView.sectionFooterHeight = 0;
sectionFooterHeight 这个距离的计算是sectionHeader + sectionFooter的高度。

  • 同时设置
self.tableView.sectionFooterHeight = 0;
self.tableView.sectionHeaderHeight = 0; 

会彻底把间隔弄走

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容