视差滚动视图(雅虎天气像) [英] Parallax view scrolling (Yahoo weather like)

查看:162
本文介绍了视差滚动视图(雅虎天气像)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不是一个严格的编程问题,而是更多的如何完成这个问题。



我很好奇(并且正在研究一个可能需要这个的应用程序)如何实现左右视差滚动。要确切地知道我的意思是检查雅虎天气应用程序(它是免费的 - 不用担心)。



他们对每个视图只使用一个视图控制器或单独的控制器在那里显示?

实现这个最简单的方法是什么?我在这里发现了这个主题解释一下,但是他们什么时候从服务器获取信息?是什么时候改变了视图或应用程序的启动?



任何有关如何实现这种滚动的信息将不胜感激。




  • 子类UIScrollView
  • 解决方案


  • 添加UIView * parallaxView; as @property

  • 添加一个CGFloat parallaxFactor作为@property

  • 重写layoutSubviews

  • 调用super,然后使用self.scrollOffset * parallaxFactor定位parallaxView



就这样!



我自己制作了一个多功能的UIScrollView子类,它非常易于使用,非常适合这种情况!在GitHub上获取: https://github.com/LeonardPauli/LPParallaxScrollView



祝您好运!

This is not strictly a programming question but more "how to accomplish this" question.

I am curious (and working on an app that will probably require this) how is left-right parallax scrolling implemented. To know exactly what I mean check the Yahoo Weather app (it's free - no worries there).

Are they using just one view controller or a separate controller for each view that is shown there?
What is the easiest way to implement this? I have found this topic here which kinda explains it a bit but when are they getting information from their servers? Is it when the views are changed or at the startup of the app?

Any information how to implement such scrolling would be much appreciated.

解决方案

It's really simple actually:

  • Subclass UIScrollView
  • Add a UIView *parallaxView; as @property
  • Add a CGFloat parallaxFactor as @property
  • Override layoutSubviews
  • Call super, and then use self.scrollOffset*parallaxFactor to position the parallaxView

That's it!

I've made a multifunctional UIScrollView subclass myself that's really simple to use, perfect for this case! Get it on GitHub: https://github.com/LeonardPauli/LPParallaxScrollView

Good Luck!

这篇关于视差滚动视图(雅虎天气像)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆