翻转 UINavigationBar 中的项目?
我的应用程序中有一个部分,我使用 UIViewAnimationTransitionFlipFromLeft 动画来更改视图。同时,我更改了 UINavigationItem
的内容以匹配新视图,特别是 titleView
和 rightBarButtonItem
。由于我只知道动画何时即将开始和结束,这似乎是我可以更新 UINavigationItem 的唯一时间。
所以,对于我的问题:
是否可以以类似的方式更改
titleView
和rightBarButtonItem
,即。使用UIViewAnimationTransitionFlipFromLeft
动画进行翻转?如果没有,有什么方法可以在视图翻转的中途更新
UINavigationItem
,而不是在动画的开始或结束时?
I have a section in my app where I am changing views by using a UIViewAnimationTransitionFlipFromLeft
animation. At the same time, I change the contents of the UINavigationItem
to match the new view, specifically the titleView
and rightBarButtonItem
. Since I only really know when the animation is about to start, and has finished, this seems to be the only times that I can update the UINavigationItem.
So, to my question:
Is it possible to change the
titleView
andrightBarButtonItem
in a similar fashion, ie. flipping with aUIViewAnimationTransitionFlipFromLeft
animation?If not, is there any way that I can update the
UINavigationItem
halfway through the view flip, rather than at the start or end of the animation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以解决 1.
您需要完全控制导航栏才能执行此操作,因此您应该摆脱
UIViewController 上使用的导航栏,并将您自己的 navBar 视图放在那里(其中有一个子视图,即 titleView和 rightBarButtonItem)。这样,您就可以像使用任何其他 UIView 一样翻转这些视图:
或
或等效的东西。希望这会有所帮助,如果您需要更多详细信息,请联系我。
You can solve 1.
You'll need full control of the navigation bar to do this so you should get rid of the one that's there using:
on your UIViewController and putting your own navBar view there instead (which would have a subview that's the titleView and the rightBarButtonItem). That way, you can flip those views as you would any other UIView using:
or
or something equivalent. Hope this helps, ping me if you need more details.
如果您使用
transitionWithView:duration:options:animations:completion:
进行过渡,您将知道持续时间。这意味着您可以使用performSelector:withObject:afterDelay:
方法在完成一半转换后运行方法。在这种方法中,您可以只更新您的导航项。If you are using
transitionWithView:duration:options:animations:completion:
to do the transition, you'll know the duration. That means you can useperformSelector:withObject:afterDelay:
method to run a method after half of the transition has been done. In this method you can then just update your navigation item.