我想制作一个UITabBarController选项卡切换动画,类似于弹出和推送导航控制器的动画。
这意味着如果我在当前选项卡的左侧选择一个选项卡,则新的viewcontroller视图将从左侧移动到屏幕中,并且旧/当前viewcontroller的视图向右移出屏幕(类似于pop )。
我目前只能做到这一点,但我不知道如何实现幻灯片输入/输出效果。
谢谢!
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController:
UIView *fromView = tabBarController.selectedViewController.view;
NSInteger fromIndex = tabBarController.selectedIndex;
UIView * toView = [viewController view];
NSInteger toIndex = [[tabBarController viewControllers] indexOfObject:viewController];
[UIView transitionFromView:fromView
toView:toView
duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve
completion:^(BOOL finished) {
if (finished) {
tabBarController.selectedIndex = toIndex;
}
}];
}