Let’s say you have a view overlaying another view that you would like to close in a fancy fashion when the user click a button, thus displaying the view directly below it. Put this code as your button’s IBAction message handler and tell me that doesn’t spice up your app like crazy! I am not going to explain how it looks, just try it. You’ll love it. It’s a nice use of code blocks too.
-(IBAction)onButtonClick:(id)sender { [UIView transitionWithView:self.view duration:0.2 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{ self.view.frame = CGRectOffset(self.view.frame, 0, -self.view.frame.size.height); } completion:^(BOOL finished) { [self.view removeFromSuperview]; [self release]; }]; }
Random Posts:
- iStrobe FREE for a week
- Sparrow 2D Game Engine for iPhone
- Make your app downloads skyrocket
- iStrobe Open Sourced Publicly
- iPhone 4 ordered – SpaceBubble HD
If you found this useful, shoot me a small donation or at the very least leave a comment, every bit of encouragement helps keep me motivated to update with more content on a regular basis!
Tags: Animation, blocks, code, Development, iPhone, Objective-C, programming, snippet, source, transitions, Xcode
You can skip to the end and leave a response. Pinging is currently not allowed.
This is a unique transition. I will be using this in my next app. It looks like a piece of paper crumbling up and away.
I was thinking the same thing. It’s actually flipping over and sliding up so fast it appears to almost crumble up.
[...] Blocks & View Transitions Snippet [...]