gpt4 book ai didi

iphone - 在 UITabController 中的选项卡之间切换时使用 'pushViewController' 动画

转载 作者:行者123 更新时间:2023-12-03 21:20:03 25 4
gpt4 key购买 nike

我在尝试使 UITabBarViewController 执行与 UINavigationController 执行 PushViewController 时相同的动画时遇到问题。

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {

UIViewController *currentVC = [tabBarController selectedViewController];
if (currentVC == viewController)
return NO;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
UIModalTransitionStyle transition = UIModalTransitionStyleFlipHorizontal;
[UIView setAnimationTransition:transition forView:tabBarController.view cache:YES];
[currentVC viewWillAppear:YES];
[viewController viewWillDisappear:YES];
[viewController viewDidDisappear:YES];
[currentVC viewDidAppear:YES];
[UIView commitAnimations];
return YES;}

以下代码在切换选项卡时执行动画:

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {

UIViewController *currentVC = [tabBarController selectedViewController];
if (currentVC == viewController)
return NO;

[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:tabBarController.view cache:YES];
[currentVC viewWillAppear:YES];
[viewController viewWillDisappear:YES];
[viewController viewDidDisappear:YES];
[currentVC viewDidAppear:YES];
[UIView commitAnimations];

return YES;}

如何修改上面的代码以执行从右侧动画的滑动,类似于将 viewController 插入导航 Controller ?

最佳答案

看看这个链接:http://haveacafe.wordpress.com/2009/04/06/animated-transition-between-tabbars-view-on-iphone/

这个想法是,您需要使用选项卡栏 Controller 的委托(delegate)方法并使用特定的动画类 CATransition (因为您是在 View 之间“转换”)。看看CATransition documentation对于动画的类型/子类型。您可能需要一种子类型为 left 或 right 的推送类型。

关于iphone - 在 UITabController 中的选项卡之间切换时使用 'pushViewController' 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5718315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com