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 especially 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. 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 Transparent Cocoa Touch application, you can see
that all the UI
Label objects
Have
a transparent background when you examine the code for these areas,
you can see where the issue lies. Specifically, look at the –init
With Frame :reuse Identifier: of
the Custom
Table View Cell object;
this is where the trouble lies .As you can see, the UI
Label objects,
title
Label and
description
Label, both
have their –background
Color set
to [UI
Color clear Color],
causing an alpha blending to occur. To correct this, change that UI
Color to be
the same color as the background for the entire UI
Table View Cell.
Author
Bio:
Haword Roze is a University Lecturer and Editor of Alpha
Male.
She loves to write on technical topics like Personal
Loan .
She is writing from last three years
No comments:
Post a Comment