Graphics Reference
In-Depth Information
CHAPTER 3
IN THIS CHAPTER
Basic Animations
. The Simplest Animations
. The Animation Proxy Object
. The Differences Between
Window, View, and Layer
Animation
C ore Animation is a powerful and mature technology
that enables you to create animations that are as simple as
you like or as complex as you need. To perform simple
animations on windows and views, Apple provides the
animation proxy object that, when called, causes an
implicit animation to play when some visual component
such as the view frame, opacity, or location is changed. For
basic layer animation, the CABasicAnimation class provides
a way to animate between two values, a starting value and
an ending value. In this chapter, we look at these most
basic methods for implementing animation in your
application.
. Preparing a View to Perform
Layer Animation
. Using CABasicAnimation
. Useful Animation Properties
. Animation Grouping
The Simplest Animations
With Core Animation integrated into Cocoa, you can
animate windows, views, and layers implicitly by simply
setting the value of the parameter you are interested in
animating to some new value. When using a layer
( CALayer ), all you need to do is set the value with a direct
call. For example, if you want to change the bounds of a
layer, you simply call [layer setBounds:newFrame] where
layer is the CALayer object you've created and added to
your layer tree and newFrame is a CGRect containing the
values of the new bound's size and origin. When this code
is run, the change to the bounds of the layer is animated
using the default animation for the keypath “bounds.”
Similarly, when using a window ( NSWindow ) or view
( NSView ), all you need to do is set the value of the window
or view property using the animation proxy object. This
means that instead of calling [view setFrame:newFrame] to
 
 
Search WWH ::




Custom Search