Blocks & View Transitions Snippet

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:

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!

Comments

*

3 Responses to “Blocks & View Transitions Snippet”

  1. Simon Singh says:

    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.

  2. Nick Vellios says:

    I was thinking the same thing. It’s actually flipping over and sliding up so fast it appears to almost crumble up.

  3. [...] Blocks & View Transitions Snippet [...]

Twitter Me