Lord Pepito
Lord Pepito

Reputation: 291

Make the transition animation last longer in IOS

I have a transition from a UIViewController to a UITabBarViewController, the transition is working perfectly but the time it takes is too fast to appreciate the effect. So I was wondering if there is a way to make this transition animation last longer?

Here is my 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];
}

This code makes a transition between my two controllers. First goes my ViewController and after 2 seconds goes my TabBarViewController. But as I was saying this animation goes too fast.

Upvotes: 2

Views: 1369

Answers (2)

Paras Joshi
Paras Joshi

Reputation: 20551

use this code...

-(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];
}

Upvotes: 2

lindon fox
lindon fox

Reputation: 3318

What iOS are you targeting? If you are happy with iOS5+, you could use Storyboards and Custom Segues.

Upvotes: 0

Related Questions