Graphics Reference
In-Depth Information
FIGURE 10-1
CAShapeLayer Displaying a Triangle
Although this example is shown to be running on iPhone OS, the
CAShapeLayer
is also
available as of Mac OS X 10.5 Snow Leopard and can be used in any application targeted
at that version of the desktop OS.
Manipulating the Path Stroke
CAShapeLayer
enables you to manipulate the appearance of the stroke around the perime-
ter of the shape you have drawn. For example, you can set the stroke width with the
lineWidth
property, or you could set the stroke color by calling
-setStrokeColor
passing
it a
CGColorRef
. Listing 10-2 demonstrates several of the fields that you can change to
manipulate the stroke of the shape.
LISTING 10-2
Path Stroke Manipulations
- (
void
)viewDidLoad
{
[
super
viewDidLoad
];
UIImage
*balloon = [
UIImage imageNamed
:
@”balloon.jpg”
];
[[[
self
view
]
layer
]
setContents
:(
id
)[balloon CGImage]];