嗨,大家好我试图弄清楚如何使用我的uitabbarcontroller滑动屏幕时从左向右过渡(反之亦然)。
这是我有多远,但我不知道如何过渡到我需要它的工作:
UIViewController * fromViewController = self.tabBarController.selectedViewController;
UIViewController * toViewController = [self.tabBarController.viewControllers objectAtIndex:index];
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[[fromViewController view] layer] addAnimation:animation forKey:@"switchToView"];
CGRect endFrame = toViewController.view.frame;
CGRect startFrame = endFrame;
startFrame.origin.x += 320;
toViewController.view.frame = startFrame;
// Transition going left and right.
[UIView transitionFromView:fromViewController.view toView:toViewController.view duration:4.0
options:UIViewAnimationOptionBeginFromCurrentState
completion:^(BOOL finished) {
toViewController.view.frame = endFrame;
if (finished) {
self.tabBarController.selectedIndex = index;
}
}];
我可以用什么方法来达到这种效果。