美文网首页
iOS-UITableView section之间间隔

iOS-UITableView section之间间隔

作者: SmileYang966 | 来源:发表于2020-05-13 18:00 被阅读0次
  1. 实现tableView每个section之间的间距为20px,理论上讲,只需设置tableView的heightForHeaderInSection以及viewForHeaderInSection,但事实上并不难work。
    后来发现Group类型的tableView,默认都有一个section footer。
    所以我们需要对section footer的高度进行控制。
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 20.0f;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc]init];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01f;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [[UIView alloc]init];
}

相关文章

网友评论

      本文标题:iOS-UITableView section之间间隔

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