【发布时间】:2015-09-14 11:24:42
【问题描述】:
我的应用程序有一个新设计,它包括用于在 tableView 顶部显示图像的视差滚动。
我知道如何通过将图像放入单元格来添加视差效果,就像这样 -
当 table scrollViewDidScroll 被调用时:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGPoint currentOffset = scrollView.contentOffset;
if (currentOffset.y > _lastContentOffset.y) {
//Scroll Up
_containerView.clipsToBounds = true;
_bottomSpaceConstraint.constant = -scrollView.contentOffset.y / 2;
_topSpaceConstraint.constant = scrollView.contentOffset.y / 2;
} else {
//Scroll Down
_topSpaceConstraint.constant = scrollView.contentOffset.y;
_containerView.clipsToBounds = false;
}
_lastContentOffset = currentOffset;
}
(_bottomSpaceConstraint 和 _topSpaceConstraint 是第 0 部分 tableView 单元格内的 Image 顶部和底部约束)
但我的问题是,当图像达到导航栏的大小时,我需要停止向上滚动。 (我的导航栏背景是透明的)我不希望图像一直到顶部。但它是我的 tableView 内的一个单元格,所以它一直到顶部,直到它在滚动时消失。我需要帮助以阻止此图像滚动。如果我想达到这个效果,可能我的做法是不正确的。
这种效果在 android 上,它被称为“折叠工具栏布局”。 http://antonioleiva.com/collapsing-toolbar-layout/
有人知道如何为 iOS 制作这种“折叠工具栏布局”效果吗?
非常感谢您的帮助!
【问题讨论】:
-
不,我想做这样的效果 - antonioleiva.com/collapsing-toolbar-layout
标签: ios objective-c uitableview scroll parallax