我正在尝试制作类似于新雅虎天气应用程序中的效果.基本上,UIPageViewController
中的每个页面都有一个背景图片,当滚动页面视图时,图片的位置只滚动大约一半的速度.我该怎么做?我想我可以在 UIPageViewController
中使用某种委托方法来获取当前偏移量,然后像这样更新图像.唯一的问题是我无论如何都无法判断 UIPageViewController
是否正在滚动!有没有办法呢?谢谢!
I am trying to make an effect similar to that found in the new Yahoo weather app. Basically, each page in the UIPageViewController
has a background image, and when scrolling through the page view, the Image's location only scrolls about half the speed. How would I do that? I thought I could use some sort of Delegate Method in the UIPageViewController
to get the current offset and then update the images like that. The only problem is that I cannot find anyway to tell if the UIPageViewController
is being scrolled! Is there a method for that? Thanks!
for (UIView *view in self.pageViewController.view.subviews) {
if ([view isKindOfClass:[UIScrollView class]]) {
[(UIScrollView *)view setDelegate:self];
}
}
这使您可以访问所有标准滚动视图 API 方法.而且这没有使用私有的 Apple API.
this gives you access to all standard scroll view API methods. And this is not using private Apple API's.
我添加了遍历子视图,以 100% 找到 UIPageViewController
的内部滚动视图警告:小心 scrollview.contentOffset.当控制器滚动到新页面时它会重置
I added traversing through subviews, to 100% find the UIPageViewController
's inner scroll view
WARNING:
Be careful with scrollview.contentOffset. It resets as the controller scrolls to new pages
如果您需要持久性 scrollview
偏移跟踪和类似的东西,最好使用 UICollectionViewController
单元格大小为集合视图本身并启用分页.
If you need persision scrollview
offset tracking and stuff like that, it would be better to use a UICollectionViewController
with cells sized as the collection view itself and paging enabled.
这篇关于告诉 UIPageViewController 何时滚动(用于图像的视差滚动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!