美文网首页
UITableView Plain样式下 sectionHead

UITableView Plain样式下 sectionHead

作者: 小海豚丶 | 来源:发表于2017-12-13 14:25 被阅读0次
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.tableView) {
        NSLog(@"%f",scrollView.contentOffset.y);
        UITableView *tableview = (UITableView *)scrollView;
        CGFloat sectionHeaderHeight = 40*kScreenWidthRatio;
        CGFloat sectionFooterHeight = 0.001;
        CGFloat offsetY = tableview.contentOffset.y;
        if (offsetY >= 0 && offsetY <= sectionHeaderHeight) {
            tableview.contentInset = UIEdgeInsetsMake(-offsetY, 0, -sectionFooterHeight, 0);
        } else if (offsetY >= sectionHeaderHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight) {
            tableview.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, -sectionFooterHeight, 0);
        } else if (offsetY >= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height) {
            tableview.contentInset = UIEdgeInsetsMake(-offsetY, 0, -(tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight), 0);
        }
    }
}

相关文章

网友评论

      本文标题:UITableView Plain样式下 sectionHead

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