iOS-UITableView section之间间隔

2020-05-13  本文已影响0人  SmileYang966
  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];
}
上一篇 下一篇

猜你喜欢

热点阅读