Using CATransition's In Three20?

1.2k views Asked by At

I am looking to implement CATransitions within TTNavigator, I know the method openURL can take a UIViewAnimationTransition but that only gives me flipping and curling animations, but with CATransition I have access to another 8, of which kCATransitionFromRight, kCATransitionFromLeft, kCATransitionFromTop, kCATransitionFromBottom are the ones I am specifically after.

With a UINavigationController would use something like this piece of code to give me more control over the animation:

    CATransition *transition = [CATransition animation];
    transition.duration = 0.5f;
    transition.timingFunction = [CAMediaTimingFunction
    functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    [self.navigationController.view.layer addAnimation:transition
    forKey:nil];

This code however, doesn't work with TTNavigator. Does anybody know how I can get my own custom animations to work with TTNavigator? Or if I am doing something wrong in my code?

2

There are 2 answers

0
Bongeh On BEST ANSWER

Turns out i answered my own question, but rather than using that last line of code to set the animation on the navigationController i was trying to set the transition to the URLAction. Once i put that line back in and commented out the URLAction transition code it seems to work!

    // create the URLAction
TTURLAction* urlAction;
urlAction = [TTURLAction actionWithURLPath:@"tt://Images"]; 
[urlAction applyAnimated:YES];

    // create the CATransition and set it to the navigation controller
CATransition *transition = [CATransition animation];
transition.duration = 0.5f;
transition.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
[self.navigationController.view.layer addAnimation:transition
forKey:nil]; 

    // tell the navigator to run the action
[[TTNavigator navigator] openURLAction:urlAction];

Hope this helps someone else in the future!

0
Dmitri Sologoubenko On

You can easily add flip or any other kind of animation on TTNavigator using TTLauncherView as follows:

- (void)launcherView:(TTLauncherView*)launcher didSelectItem:(TTLauncherItem*)item {
    TTURLAction* action = [TTURLAction actionWithURLPath:item.URL];
    [action setAnimated:YES];
    [action setTransition:UIViewAnimationTransitionFlipFromLeft];
    [[TTNavigator navigator] openURLAction:action];
}

This makes TTNavigator use animated transition while displaying new URL.