Graphics Reference
In-Depth Information
Figure 4.19
A sharp clock display, achieved by using nearest-neighbor scaling
UIView
has a handy
alpha
property that can be used to vary its transparency.
CALayer
has an equivalent property called
opacity
. Both properties work hierarchically, so if you
set the
opacity
of a layer it will automatically affect all of its sublayers, as well.
A common trick in iOS is to set a control's
alpha
to 0.5 (50%) to make it appear disabled.
This works great for individual views, but when a control has subviews it can look a bit
strange. Figure 4.20 shows a custom
UIButton
containing a nested
UILabel
; on the left
is an opaque button, and on the right is the same button shown with 50% alpha. Notice how
we can see the outline of the internal label against the button background.