我试图隐藏一个与卷轴同步的元素。但是滚动弹跳效果把我的动画搞砸了。
override func scrollViewDidScroll(scrollView: UIScrollView) {
if (self.lastContentOffset > scrollView.contentOffset.y) {
"Animate UIView up"
}
else if (self.lastContentOffset < scrollView.contentOffset.y){
"Animate UIView down"
}还有什么其他的方法可以让我不被弹跳弄乱就能得到我正在燃烧的方向吗?我也不想让弹跳失效。
此外,由于我是动画我的uiview同步到滚动,如我滚动10 or,然后uiview高度应该最小化10 or,然后我需要布局需要()或任何其他功能?
发布于 2015-08-06 15:01:27
当它弹跳时,你可以假设它在滚动“越界”,你可以这样检查它,只有当它没有超出界限时才能激活视图。
//Bouncing at the bottom
scrollView.contentOffset.y + scrollView.bounds.size.height > scrollView.contentSize.height;
// Bouncing at the top
scrollView.contentOffset.y < 0如果contentInset属性与UIEdgeInsetZero不同,则可能需要调整此代码。
https://stackoverflow.com/questions/31858992
复制相似问题