I'd like to make a UITabBarController tab switching animation similar to pop and push animation of navigation controller.
That's means if I select a tab at the left of the current tab, the view of new viewcontroller move into the screen from the left, and the view of old/current viewcontroller move out of screen to the right (similar to pop).
I can only achieve this at the moment but I don't know how to implement slide in/out effect.
Thank you!
-(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;
}
}];
}