我使用這個函數,它接受目標視圖的索引。我將添加此函數作爲父視圖控制器的一部分,由子視圖控制器調用。這取決於你。
-(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;
}
}];
}
來源
2013-03-19 08:47:27
gps
的可能重複[iPhone:如何用動畫切換標籤(http://stackoverflow.com/questions/5161730/iphone-how-to-switch-tabs-with -an動畫) –