Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform kCATransitionPush animation without any transparency / fade effects [duplicate]

Possible Duplicate:
iPhone CATransition adds a fade to the start and end of any animation?

I'm trying to duplicate the "slide up from the bottom" animation that [UIViewController presentModalViewController:animated:] performs but without calling it because I don't want a modal view.

The below core animation code comes very close but appears to be changing transparency values of the views during it. At the start of the animation you can partially see through the view sliding up. By the middle/end of the animation the view we are sliding over is fully transparent so we can see behind it. I'd like both to remain fully opaque during this animation.

Any ideas on how to stop transparency changes in this code or to otherwise get the "slide up animation" I am looking for without requiring a modal view?

UIViewController *nextViewController = [[UIViewController alloc] autorelease];
nextViewController.view.backgroundColor = [UIColor redColor];  
CATransition *animation = [CATransition animation];
animation.duration = 3.5;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromTop;  
[self.navigationController pushViewController:nextViewController animated:NO];
[self.navigationController.view.layer addAnimation:animation forKey:nil];
like image 698
Anthony Avatar asked Apr 22 '10 00:04

Anthony


1 Answers

The simplest method is to simply use UIView beginAnimations/commitAnimations block. You can adjust the duration and curve by reviewing the docs.

{   
    // Adjust for orientation as necessary.
    view.frame = CGRectMake(0,
                        -480, 
                        320,
                        480);

    [UIView beginAnimations:nil context:nil];

    view.frame = CGRectMake(view.frame.origin.x,
                        0, 
                        view.frame.size.width,
                        view.frame.size.height);

    [UIView commitAnimations];
}

Docs here:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html

like image 119
logancautrell Avatar answered Sep 27 '22 18:09

logancautrell