翻转 UINavigationBar 中的项目?

发布于 2024-11-24 02:41:10 字数 496 浏览 0 评论 0原文

我的应用程序中有一个部分,我使用 UIViewAnimationTransitionFlipFromLeft 动画来更改视图。同时,我更改了 UINavigationItem 的内容以匹配新视图,特别是 titleViewrightBarButtonItem。由于我只知道动画何时即将开始和结束,这似乎是我可以更新 UINavigationItem 的唯一时间。

所以,对于我的问题:

  1. 是否可以以类似的方式更改 titleViewrightBarButtonItem,即。使用 UIViewAnimationTransitionFlipFromLeft 动画进行翻转?

  2. 如果没有,有什么方法可以在视图翻转的中途更新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:

  1. Is it possible to change the titleView and rightBarButtonItem in a similar fashion, ie. flipping with a UIViewAnimationTransitionFlipFromLeft animation?

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

把时间冻结 2024-12-01 02:41:10

您可以解决 1.

您需要完全控制导航栏才能执行此操作,因此您应该摆脱

self.navigationController.navigationBarHidden = YES;

UIViewController 上使用的导航栏,并将您自己的 navBar 视图放在那里(其中有一个子视图,即 titleView和 rightBarButtonItem)。这样,您就可以像使用任何其他 UIView 一样翻转这些视图:

+[UIVIew setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache]

+[UIVIew transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion]

或等效的东西。希望这会有所帮助,如果您需要更多详细信息,请联系我。

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:

self.navigationController.navigationBarHidden = YES;

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:

+[UIVIew setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache]

or

+[UIVIew transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion]

or something equivalent. Hope this helps, ping me if you need more details.

双马尾 2024-12-01 02:41:10

如果您使用 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 use
performSelector: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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文