Graphics Reference
In-Depth Information
Minimize Alpha Blending
Similar to the nested transforms discussed earlier, alpha blending is also calculated in real
time. When a layer has partial transparency, that transparency is recalculated for every
frame of an animation. Beware of this when animating layers that have transparency, and
try to minimize the calculations as much as possible. Sliding layers behind other layers
that are transparent can incur a large performance penalty.
Fortunately, there is an easy way to
determine which layers have alpha
blending and remove it. This is espe-
cially useful on the iPhone with its
limited resources. To check for alpha
blending, launch your application on
the iPhone with Instruments running
on the desktop. In Instruments, add the
Core Animation instrument in addition
to any others you want to use.
When your application runs on the
iPhone and you have Instruments
attached to it, to turn on the Color
Blended Layers, switch in the Core
Animation Instrument, as shown in
Figure 12-1.
FIGURE 12-1 The Color Blended Layers
Switch in Instruments
As soon as you enable this switch, you
see an immediate effect on the iPhone.
The entire iPhone screen turns either red
or green. In fact, this switch can be
turned on without any applications
running, and you can see its effect
on the home screen, as shown in
Figure 12-2.
When enabled, the Color Blended
Layers option colors the layers, so you
can quickly identify the trouble spots in
your app. Areas marked in green do not
have any alpha blending, whereas areas
marked in red do. The goal with this is
to eliminate as much of the red as
possible. For example, in the
T ransparentCocoaTouch application,
you can see that all the UILabel objects
have a transparent background, as
shown in Figure 12-3.
FIGURE 12-2 Color Blended Layers Mode on
the iPhone Springboard
Search WWH ::




Custom Search