[英]Instagram-style navigation bar hiding
I need to hide the navigation bar when the user scrolls down. 当用户向下滚动时,我需要隐藏导航栏。 Currently, I'm calling
setNavigationBarHidden: YES animated:YES
on scroll, but this solution isn't ideal as it makes the main view jump up as soon as the animation is called. 目前,我正在调用
setNavigationBarHidden: YES animated:YES
滚动时为setNavigationBarHidden: YES animated:YES
,但此解决方案并不理想,因为它会在调用动画时立即跳转到主视图。
The Instagram app has a much better solution - the navigation bar is locked to the top of the main view, and it scrolls up as the user scrolls. Instagram应用程序有一个更好的解决方案 - 导航栏锁定在主视图的顶部,并在用户滚动时向上滚动。 Scroll down a few pixels, and only part of the nav bar gets hidden.
向下滚动几个像素,只有部分导航栏被隐藏。
Any ideas on how this could be accomplished? 关于如何实现这一点的任何想法?
Check out https://github.com/andreamazz/AMScrollingNavbar . 查看https://github.com/andreamazz/AMScrollingNavbar 。 Its very easy to use, just subclass
AMScrollingNavbar
in your viewController 它非常容易使用,只要继承
AMScrollingNavbar
在你的viewController
I don't think they are using a navigation bar. 我认为他们没有使用导航栏。 I think it's custom header view for the UITableView, or at least that's what I would do since you can put any UIView there.
我认为它是UITableView的自定义标题视图,或者至少我会做什么,因为你可以把任何UIView放在那里。
You can use the UITableView delegate to set those headers. 您可以使用UITableView委托来设置这些标头。
navigation bar doesn't provide this function. 导航栏不提供此功能。 the best way is to use a custom view (your custom navigation bar) as a subview of the main view, then do the animations yourself, using functions like [UIView animateWithDuration ....] with translation function using something like CATransform3DTranslate
最好的方法是使用自定义视图(您的自定义导航栏)作为主视图的子视图,然后自己动画,使用像[UIView animateWithDuration ....]这样的函数,使用像CATransform3DTranslate这样的翻译函数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.