集合视图滚动时的滚动视图

时间:2017-08-09 09:03:40

标签: ios swift3 uicollectionview autolayout

我希望在集合视图滚动时滚动UIView,如下面的视频

所示

enter image description here

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    print(scrollView.contentOffset.x)

    let contentSize = self.propertyImageCollectionView.contentSize

    let xOffSet = (((scrollView.contentOffset.x * self.propertyImageCollectionView.frame.width) / (contentSize.width - self.progressViewWidthConstratint.constant)))

    let xValue = xOffSet + ((self.progressViewWidthConstratint.constant * self.progressViewLeadingConstraint.constant) / self.propertyImageCollectionView.frame.width)

    print( self.progressViewWidthConstratint.constant)
    print( xOffSet)
    print(xValue)

     if xValue > 0 && xValue < self.propertyImageCollectionView.frame.width - self.progressViewWidthConstratint.constant{
        self.progressViewLeadingConstraint.constant = xValue
    }
}

视图不会滚动到屏幕的末尾。它会在某些点之前停止滚动。我在哪里缺乏代码。我也尝试使用KVO但没有成功。你有其他方法吗?

0 个答案:

没有答案
相关问题