Graphics Reference
In-Depth Information
Figure 7.1 Adding a button to change the layer color
This kind of animation is known as implicit animation. It is implicit because we are not
specifying what kind of animation we want to happen; we just change a property, and Core
Animation decides how and when to animate it. Core Animation also supports explicit
animation, which is covered in the next chapter.
When you change a property, how does Core Animation determine the type and duration of
the animation that it will perform? The duration of the animation is specified by the settings
for the current transaction , and the animation type is controlled by layer actions .
Transactions are the mechanism that Core Animation uses to encapsulate a particular set of
property animations. Any animatable layer properties that are changed within a given
transaction will not change immediately, but instead will begin to animate to their new
value as soon as that transaction is committed.
Transactions are managed using the CATransaction class. The CATransaction
class has a peculiar design in that it does not represent a single transaction as you might
expect from the name, but rather it manages a stack of transactions without giving you
direct access to them. CATransaction has no properties or instance methods, and you
can't create a transaction using +alloc and -init as normal. Instead, you use the class
methods +begin and +commit to push a new transaction onto the stack or pop the
current one, respectively.
Any layer property change that can be animated will be added to the topmost transaction in
the stack. You can set the duration of the current transaction's animations by using the
+setAnimationDuration: method, or you can find out the current duration using the
+animationDuration method. (The default is 0.25 seconds.)
Search WWH ::




Custom Search