Graphics Reference
In-Depth Information
also set the animationDidStopSelector so that the animation has a method to call upon
completion.
Next, because we want the animation to repeat, set the animationRepeatCount to 3 and
set the animationRepeatAutoreverses to YES . This gives the illusion of the image bounc-
ing three times.
The last setting to perform is actually moving the image. First grab the current center
point of the UIImageView and then increase the y by 100 pixels. Then set that adjusted
CGPoint back as the new center for the UIImageView and commit the animation.
When the animation is complete, the same animation is performed on the button, except
in reverse, by setting its alpha value to 1.0 . The implementation of this method is shown
in Listing 13-17.
LISTING 13-17
MainViewController.m -action: Implementation
- ( void )viewAnimationDone:( NSString *)name
{
[ UIView beginAnimations : @”Show Button” context : nil ];
[[ self button ] setAlpha :1.0];
[ UIView commitAnimations ];
}
The end result is a fairly convincing bounce of the image view. This same technique can
be used to slide an element onto the view, cause things to fade in and out, or create virtu-
ally any other animation that acts on the animatable properties of a view.
Summary
Using Core Animation in Cocoa Touch is similar to the Desktop, and most of the tech-
niques that we learned throughout this topic can be used interchangeably. The primary
issue we need to be concerned with in Cocoa Touch is performance. The current devices
that run Cocoa Touch are significantly less powerful than any modern desktop computer,
and it is much easier to overload them with animations, resulting in poor performance.
 
 
Search WWH ::




Custom Search