Update: thanks to Elliott's comment, I was able to remove the screen capturing portion of the code since UIKit captures the screen FOR us immediately before the animation fires. This eliminates a lot of memory usage. Thanks Elliott!
I'm a big fan of the Square iPhone app. It is a great service with a beautiful and extremely well-designed interface.
But this isn't a commercial for Square—I'm going to walk you through step-by-step how to implement that really cool page curl animation they use when you hit the "Clear" button. Don't know what I'm talking about? Here's the effect in action:
There are four basic steps involved in creating this effect:
Add a blank transparent UIView to your stack.
Do all the clearing of interface elements and reset everything the way you want.
Initialize the page curl effect to peel away the dummy UIView.
Remove the UIView from the view hierarchy and then from memory.
Here's a demo video of what we're going to make:
Let's walk through the steps. (Note: This tutorial assumes you know how to create IBOutlets and IBActions and connect them in Xcode's Interface Builder view.)
First we want to create an IBAction for your button that's going to initialize the action. Create the method in your .m and .h files and wire up the action to the appropriate interface element (usually a UIButton).
Here's my IBAction that's wired to my UIButton in the interface:
As you can see from all the inline comments: I created the view, added the view as a subview to my view controller's main view, cleared everything off the screen, peeled back that subview, and released it from memory.
Check out the example project on github. Fork it and use it!
Feel free to leave comments, improvements, or alternate solutions below.