2

我有一个从 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。但正如我所说,这个动画太快了。

4

2 回答 2

2

使用此代码...

-(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];
}
于 2012-12-12T05:10:33.967 回答
0

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

于 2012-12-12T05:07:46.993 回答