【问题标题】:Make the transition animation last longer in IOS让转场动画在 IOS 中持续更长时间
【发布时间】:2012-11-29 18:24:07
【问题描述】:

我有一个从 UIViewController 到 UITabBarViewController 的过渡,过渡效果很好,但是欣赏效果所花费的时间太快了。所以我想知道是否有办法让这个过渡动画持续更长时间?

这是我的 AppDelegate.m

@implementation AppDelegate

@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
@synthesize LoadingViewController = _LoadingViewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

     self.window.rootViewController = self.LoadingViewController;
    [self.window addSubview:tabBarController.view];
    [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(changeView) userInfo:nil repeats:NO];


    [self.window makeKeyAndVisible];
    return YES;
}

-(void)changeView{

    self.tabBarController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 



    [self.window.rootViewController presentModalViewController:self.tabBarController animated:YES];
}

这段代码在我的两个控制器之间进行了转换。首先是我的 ViewController,2 秒后是我的 TabBarViewController。但正如我所说,这个动画太快了。

【问题讨论】:

    标签: iphone ios animation transitions


    【解决方案1】:

    使用此代码...

    -(void)changeView{
    
      //  self.tabBarController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
           CATransition *animation = [CATransition animation];
            [animation setDelegate:self];   
            [animation setType:kCATransitionFade];
            [animation setDuration:0.5];// increase time duration with your requirement
            [animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                                          kCAMediaTimingFunctionEaseInEaseOut]];
            [[self.window layer] addAnimation:animation forKey:@"transitionViewAnimation"];
    
    
       self.window.rootViewController = self.tabBarController;
       [self.window makeKeyAndVisible];
    }
    

    【讨论】:

    • @LordPepito 我想你想在应用程序加载时启动 2 秒然后你想用标签栏控件显示应用程序吗?如果你想要这个然后使用我更新的答案我现在更新答案
    • 是的,这就是我想要做的......而且你提供给我的代码真的很有帮助,效果很好。感谢您抽出宝贵时间@Paras Joshi
    【解决方案2】:

    您的目标是什么 iOS?如果您对 iOS5+ 满意,可以使用 Storyboards 和 Custom Segues。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-18
      • 1970-01-01
      • 2021-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多