我如何将collectionView发送到层次结构的顶部

时间:2019-06-25 09:02:47

标签: swift

我有一个带有图像的标头容器。集合视图具有带有UITapGesture的插入和标题容器。在集合视图上打手势,这就是问题所在。

let offsetY = scrollView.contentOffset.y

let y = (Constants.headerHeight - (scrollView.contentOffset.y + Constants.headerHeight) - heightTop)

let height = min(max(y, 0), Constants.headerHeight) // Step: 1 - Calculate height for next step

viewContainer.center = CGPoint(x: height / 2, y: height / 2) // Step: 2 - Setting center of container while scrolling

headerTopConstraint.constant = -(((scrollView.contentOffset.y + Constants.headerHeight) / 2) - (heightTop / 2)) // Step: 3 - Formula for padding to headerTopConstraint

viewButtonFavorite.alpha = max(min((-offsetY - (Constants.headerHeight + 44))/19, 1), 0)

0 个答案:

没有答案