views:

505

answers:

3

I'm looking to have my main view shrink to reveal the next view in the same way the Facebook app's views shrink when you press the top-left button. I already have it working with one of the included animations like this:

[UIView beginAnimations:nil context:nil];  
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
[UIView setAnimationDuration:1.0];  
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];  
[self.navigationController popToRootViewControllerAnimated:YES];  
[UIView commitAnimations];

However, since "Shrink" isn't one of the included animations, I'm a bit stuck. How could I make this shrink instead?

I'm fairly well-experienced with the iPhone SDK but haven't spent a lot of time with UIView animations.

A: 

Have you tried combining a scaling and translating transformation?

Neosionnach
A: 

Here is my tutorial showing how to make expanding views like in the facebook app, please let me know what you think:

How to make expanding/shrinking views on iPhone SDK

Adam

Adam
That'd be great! Thanks.
Moduspwnens
Check my edited post :) Let me know what you think,Adam
Adam
Just checked it out: That's exactly what I was looking for. Thanks a lot!
Moduspwnens
Glad I could be a help :)Good luck with your project,AdamP.S. Maybe you could click the little up arrow to the left of my post :P
Adam
A: 

UIView's setAnimationTransition: method makes the packaged set of animations dirt simple, but if you want to do something else, you have to drop down a level and use Core Animation itself.

It isn't too bad: basically you use CATransaction's begin and commit methods and in between, get the view's layer and set its transform property directly. To shrink it you could set the scale to 0.00001, causing it to shrink.

Instead of removing the view right away, you will have to set a completion block and remove it yourself when the animation is done. And you might want to reset the transform back to normal, if you plan to use the view again.

benzado