iPhone - 动画 TabBarController 开关
我通过代码切换选项卡:
self.tabBarController.selectedIndex = 1; // or any other number
选项卡之间的切换工作正常。我想知道是否有一种方法可以使过渡动画化。它必须仅在本例中,而不是一般的整个 tabbarcontroller。也就是说,仅当通过该特定代码段切换选项卡时才会发生转换。当单击实际选项卡项时,它应该是瞬时的(没有动画)。
如果有人可以提供帮助,我们将不胜感激。
I am switching tabs through code with this:
self.tabBarController.selectedIndex = 1; // or any other number
The switching between the tabs works fine. I'm wondering if there is a way to animate the transition. It'd have to be only in this instance, not the total tabbarcontroller in general. That is to say that the transition will only take place when the tab is switched through that specific piece of code. It should be instantaneous(without animation) when the actual tab item is clicked.
If anyone can help, help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果标签栏控制器没有任何复杂的操作,您可以从 UITabBar 中推出自己的控制器,然后在切换标签时可以执行任何操作。您只需实现
UITabBarDelegate
。以下是对我在应用程序中使用的示例代码进行了稍微修改的示例代码:.h 文件:
.m 文件:
在 didSelectItem 内,您可以执行任何您想要的动画。我只是立即交换 alpha,但你可以随心所欲地复杂化。
If you don't have anything complicated going on with the tab bar controller, you can roll your own from a UITabBar and then you can do anything you want when you switch tabs. You just implement the
UITabBarDelegate
. Here is example code slightly modified from what I'm using in an app:.h file:
.m file:
Inside didSelectItem you can do any animation you want. I just do an immediate swap of the alpha, but you can be as complicated as you want.