UITableViewStyleGro

作者: 傲骨天成科技 | 来源:发表于2017-06-24 10:45 被阅读49次

    一、UITableViewStylePlain

    1.有多段时 段头停留(自带效果)

    2.没有中间的间距和头部间距(要想有的重写UITableViewCell \UITableViewHeaderFooterView里面的setFrame方法)

    扩展:让段头不停留(取消粘性效果)

    • (void)scrollViewDidScroll:(UIScrollView *)scrollView {

      CGFloat sectionHeaderHeight = 30;
      if(scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {

        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
      

      } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {

        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
      

      }

    }

    二、UITableViewStyleGroup

    注意:去掉头部和中间间隔

    正确的理解方法

    1.设置标头的高度为特小值 (不能为零 为零的话苹果会取默认值就无法消除头部间距了)

    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0.001)];
    view.backgroundColor = [UIColor redColor];
    self.tableView.tableHeaderView = view;

    2.写代理方法(中间的留白其实是段尾的高度 代理的作用设置段尾的高度 返回值也不能为0)

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

    三、在遇见tableView的cell距离tableView的顶部或者底部有距离是,可以通过下面方法解决:
    self.tableView.contentInset = UIEdgeInsetsMake(-44, 0, 0, 0);

    相关文章

      网友评论

        本文标题: UITableViewStyleGro

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