[英]How to add transition for switching between tabbar viewcontrollers
I added UITabBarViewController
to my app and added five ViewControllers
. 我将
UITabBarViewController
添加到我的应用程序中,并添加了五个ViewControllers
。 Each VC
to one of the TabBarItems
. 每个
VC
到TabBarItems
。 And all of this is working good. 所有这些都运行良好。 But for the third
view
is made for user to input some data, so I want it to be presented as temporary VC
. 但是由于第三个
view
是供用户输入一些数据的,因此我希望将其显示为临时VC
。 The usual transition for temporary VC
is crossdisolve. 临时
VC
的通常过渡是交叉溶解。 This brings the VC
up from the bottom. 这使
VC
从底部开始。
So my question is how can I make this animation for transition between TabBarItems . 所以我的问题是如何制作此动画以在TabBarItems之间进行过渡 。
I use this function which takes in the index of the destination view. 我使用此函数接收目标视图的索引。 I would add this function as part of the parent view controller to be called by the sub-view controllers.
我将此功能添加为要由子视图控制器调用的父视图控制器的一部分。 That's up to you.
随你(由你决定。
-(void) animateTabBarTransition:(NSInteger) destinationTabIdx{
UIView * fromView = self.tabBarController.selectedViewController.view;
UIView * toView = [[self.tabBarController.viewControllers objectAtIndex:destinationTabIdx] view];
[UIView transitionFromView:fromView toView:toView duration:0.8
options:(destinationTabIdx > self.tabBarController.selectedIndex ? UIViewAnimationOptionTransitionFlipFromLeft: UIViewAnimationOptionTransitionFlipFromRight)
completion:^(BOOL finished) {
if (finished) {
self.tabBarController.selectedIndex = destinationTabIdx;
}
}];
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.