tableView section随cell移动 ,不在顶到屏幕顶部

时间:2022-09-15 22:21:45

 

加上这段代码即可


 func scrollViewDidScroll(scrollView:UIScrollView) {

        let sectionHeaderHeight:CGFloat = 55

        if scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y > 0 {

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

        }

        elseif scrollView.contentOffset.y >= sectionHeaderHeight {

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

        }

    }