Graphics Reference
In-Depth Information
.
mask
The mask property is itself a layer. The opacity of the mask layer determines how the
effect renders. When you specify a mask, keep in mind that that the mask bounds
determine what is allowed to show through rather than what is blocked from view.
In other words, if you specify the width and height of the mask layer to be 300
×
300 pixels and specify the center of the window as the mask layer's position prop-
erty, you see a 300
300 portion of the containing layer show through in the center
of the window. The surrounding part of the 300
×
×
300 square is what is actually
masked, as illustrated in Figure 2-3.
FIGURE 2-3
A Simple Mask Layer
.
masksToBounds
The masksToBounds property
ensures that content is clipped to
the bounding rectangle. It is
particularly useful when you have
set a corner radius on a layer with
content and want to ensure that
the content doesn't spill to the
outside of the content rectangle
where the rounded corners are.
NOTE
At the time of this writing, there is no way to
simply invert the mask. If you want to mask
the surrounding area instead, you must draw
and fill the appropriate path in the mask
layer with -drawInContext in a derived layer
or use -drawLayer:inContext if you use a
delegate.
Search WWH ::




Custom Search