Move a view when scrolling in UITableView

前端 未结 9 1938
孤街浪徒
孤街浪徒 2020-12-04 11:42

I have a UIView with a UITableView below it:

\"enter

9条回答
  •  抹茶落季
    2020-12-04 12:02

    Swift 3 & 4:

        var oldContentOffset = CGPoint.zero
        let topConstraintRange = (CGFloat(0).. 0 && yourConstraint.constant > topConstraintRange.lowerBound && scrollView.contentOffset.y > 0 {
                yourConstraint.constant -= delta
                scrollView.contentOffset.y -= delta
            }
    
            //we expand the top view
            if delta < 0 && yourConstraint.constant < topConstraintRange.upperBound && scrollView.contentOffset.y < 0{
                yourConstraint.constant -= delta
                scrollView.contentOffset.y -= delta
            }
            oldContentOffset = scrollView.contentOffset
        }
    

提交回复
热议问题