That is my code
personal let parentScrollView = UIScrollView()
personal let scrollViewContentView = UIView()
personal let tableView = UITableView(body: CGRect.zero, type: .plain)
// MARK: Setting Scroll View
extension ViewController{
personal func setupParentScollView() {
self.view.addSubview(parentScrollView)
parentScrollView.delegate = self
parentScrollView.isScrollEnabled = false
}
personal func addParentScollViewConstraints() {
parentScrollView.snp.makeConstraints { make in
make.left.high.proper.backside.equalTo(self.view.safeAreaLayoutGuide)
}
}
}
// MARK: Setting Scroll View’s Content material View
extension ViewController{
personal func setupScollViewContentView() {
self.parentScrollView.addSubview(scrollViewContentView)
}
personal func addScollViewContentViewConstraints() {
scrollViewContentView.snp.makeConstraints { make in
make.edges.equalTo(parentScrollView) // Set constraints to cowl the complete scrollView.
make.width.equalTo(parentScrollView)
}
}
}
// MARK: – Setting Up TabelView
extension ViewController{
personal func setupTableView() {
scrollViewContentView.addSubview(tableView)
tableView.delegate = self
tableView.dataSource = self
tableView.separatorStyle = .none
tableView.showsVerticalScrollIndicator = false
tableView.bounces = false
tableView.contentInset = UIEdgeInsets(high: 0, left: 0, backside: 100, proper: 0)
print("that is from tableView",tableView.type)
if #obtainable(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = 0
}
}
func addTableViewConstraints() {
tableView.snp.makeConstraints { (make) in
make.high.equalTo(searchBottomPaddingView.snp.backside).offset(100)
make.left.proper.backside.equalTo(scrollViewContentView)
make.top.equalTo(parentScrollView.snp.top)
}
}
}
extension ViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView == tableView {
let offsetY = tableView.contentOffset.y
print("that is from scrollView", offsetY, parentScrollView.contentOffset.x)
if offsetY > 0 && offsetY <= 120 {
// Scrolling down, transfer the parentScrollView up by 120 factors
parentScrollView.setContentOffset(CGPoint(x: parentScrollView.contentOffset.x, y: 120), animated: true)
}
if offsetY == 0{
// Scrolling down, transfer the parentScrollView up by 120 factors
parentScrollView.setContentOffset(CGPoint(x: parentScrollView.contentOffset.x, y: 0), animated: true)
}
}
**right here, I do not need to scroll the header of the tableView however since it’s contained in the contentView of scrollView it’s scrolling with it
I usually need to acquire parallax impact whereas scrolling, please assist me.
**