Using Basic iPhone Animations
When working on my first iPhone project, I discovered that the use of basic animations can really enhance the quality of the user experience.
Some personal favorites of mine are dynamic position adjustment and fade effects.
For example, if you have a UITextView named textView that you want near the bottom of a page, but it keeps getting covered up with the keyboard when you go to type in it, animations are a perfect solution:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
textView.frame = CGRectMake(textView.frame.origin.x,
textView.frame.origin.y - 150,
textView.frame.size.width,
textView.frame.size.height);
[UIView commitAnimations];
This will shift textView up 150 pixels in a smooth animated fashion. When the user is done, simply add a reverse animation to the action used to dismiss the keyboard. Also, make sure to animate any associated frames/labels as well, lest your UITextView leave them behind.
A similarly simple use of animations is to dynamically fade in content as it becomes available. In one of my own applications, we use this to load images in the background (using threading) while displaying a UIActivityIndicator.
When the image is ready to be displayed, we stop the load indicator and use animations to fade in the UIImageView. Assuming it is named myImage, this would work as shown below.
First we initially set the alpha to 0:
[self.myImage setAlpha:0.0];
Then, when the image is done loading, we display it:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[self.myImage setAlpha:1.0];
[UIView commitAnimations];
Using this simple animation avoids any jarring appearance of the image and creates an easy mechanism to display loaded images.