Using view transitions will give a lot of beauty to your entire application. So far there are implemented 4 transitions:
- Curl Up (UIViewAnimationTransitionCurlUp) – check Maps application on iPhone, but it’s not best example. Simply: page flip; curls a view up from the bottom
- Curl Down (UIViewAnimationTransitionCurlDown)
- Flip from right (UIViewAnimationTransitionFlipFromRight) - execly the same like in Weather app when you press info button; flips a view around a vertical axis
- Flip from left (UIViewAnimationTransitionFlipFromLeft)
The code for setting a view transition is almost the same like for any other animation, here is the example:
[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1.5]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:placeholder cache:YES]; [view1 removeFromSuperview]; [placeholder addSubview:view2]; [view2 removeFromSuperview]; [placeholder addSubview:view1]; [UIView commitAnimations];
I have a view called placeholder and it’s added as a part of self.view of the view controller. view1 and view2 are two different views I want to transit go from view1 to view2 and vice verse. placeholder is of the same size as both view1 and view2. During this animation / transition placeholder flips around hiding view1 and revealing view2. During the transition, everything what is below placeholder is partialy visible. The animation takes 1.5 seconds as u set in setAnimationDuration.
Please note #1:
It’s only an animation, not real rotation / flip of placeholder let’s say it an optical illusion. UIView (what placeholder is) doesn’t have something like back and front side. view1 after transition is not hidden behind the placeholder, it has been removed, and you still see the front side of placeholder although it’s covered by view2, which is a placeholder’s subview.
Please note #2:
Unfortunately you can’t see the curl up / down transition on iPhone Simulator, it looks like fade, but it really works on real device.
Please note #3:
If view that animate’s in my case placeholder (yes placeholder animates, view1/view2 are only added/removed) is bigger than view1/view2 you will always see front site of that part although it will animate too.
Please note #4:
If you see annoying white part during animation, simply add something black below the placeholder – another view or image for example.
Fade transition
As I told you there are only 4 transitions, but many are curious how to make the fade transition. It’s very easy, simply create a normal animation which will change the alpha property for both views:
[placeholder addSubview:view2]; [placeholder addSubview:view1];
view2.alpha = 0; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1.5]; view1.alpha = 0; view2.alpha = 1; [UIView commitAnimations];
I prepared for you a project you can download and test Curl Up, Curl Down, Flip From Right, Flip From Left, Fade and also Flip From Left again but along the self.view, not placeholder.




You did great job . Really Its very helpful for my application.
Continue your job for iphone developers.
look videos watch
I really wish I hadn’t seen this as I really want one now! This is all very new to me and this article really opened my eyes.Thanks for sharing with us your wisdom. http://www.charmhandbags.com
I would like to consider the chance of saying thanks to you for your professional guidance I have usually enjoyed visiting your site. I will be looking forward to the commencement of my school research and the whole planning would never have been complete without checking out your site. If I may be of any assistance to others, I’d personally be happy to help as a result of what I have discovered from here.
I adore that weblog structure . Exactly how had been it produced? It’s very cool!
What if I don’t wish to actually add/remove the 2 views. Can I just hidden/unhidden the 2 views? Doesn’t seem to work.
Also… I’m not trying to flip the entire window… but rather… just my 2 small objects. (2 small UITextViews.)
What if I don’t wish to actually add/remove the 2 views. Can I just hidden/unhidden the 2 views? Doesn’t seem to work.
Also… I’m not trying to flip the entire window… but rather… just my 2 small objects. (2 small UITextViews.)
Thank God! Somoene with brains speaks!
Youre so cool! I dont suppose Ive read something like this before. So good to search out somebody with some original thoughts on this subject. realy thank you for beginning this up. this web site is something that’s needed on the internet, somebody with just a little originality. helpful job for bringing something new to the internet!
Awesome post ! Cheers for, posting on my blog man! I shall message you soon. I didn’t realise that.
i want it
Thats lovely stuff you written up in here. Have been hunting for reviews on this everywhere. Great blog
Thank you for another fantastic blog. Where else could I get this kind of info written in such an incite full way? I have a presentation that I am just now working on, and I have been looking for such information.
Advantageously, the post is actually the sweetest topic on this registry related issue. I fit in with your conclusions and will thirstily look forward to your future updates. Just saying thanks will not just be enough, for the extraordinary clarity in your writing. I will immediately grab your rss feed to stay informed of any updates.
Why is this done in the delegate files? I’m a bit of a newb, and many of the examples I see start with creating a new project which create delegate h and m files. Can this code be pasted into my project h and m files to work along with the other code I have there?
Great tutorial, informative and to the point!!!
How does one know when an animation is animating or has completed the animation, like a duringAnimation or animationComplete event?
A ha! Should have googled this before asking, would this work? I guess so…
http://kwigbo.com/post/269410529/animate-adding-a-uiview-call-function-when-the
Many many tnx:) it was better than expected:)
Now, with the new simulator, CURL effects are visible!
Thx
Yes they are, but I don’t have time to update my tutorials. I’m busy with bureaucracy, app development, contracts…
Chris
Chris thank you so much. This is a great job you are doing.
your tutorials are very helpful for me. Saving lot of time and energy.
Thanks once again please come up with more good ones.
thanks
ashish
-(void)FadeAnimation {
[UIView beginAnimations:nil context:NULL];
//[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:animationView cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[myView setAlpha:0];
// Animations
//[[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
// Commit Animation Block
[UIView commitAnimations];
}
This is what I use. This is a -(void), but everything inside can be placed in an -(IBaction). The only thing that you change is the myView, you change it to the view or sub view that you want to fade. This is good for intros splash screens. I use this with timers and have the view that fades out hide the second the animation is over.
Hi,
Really useful example. and downloadable code.
thanks,
Aaryan