Bézier Path Arrow Demo
Some other operating systems provide a built-in way to add arrows to the ends of lines. Mac OS X, in contrast, leaves it up to you to figure out how to do this, and in some cases the results haven’t been particularly pretty.
This program is a demo that I wrote way back in 2004, showing one way to add
arrows to arbitrary
NSBezierPaths. In particular, drawing an arrowhead is
as simple as
1 2 3 4
There’s a similar method for obtaining an arrowhead path for the end of your path.
The code works by chopping off a short segment of the path, rotating it
through the specified angle in either direction and joining the ends together.
By default, you get an open path with just the two sides, but obviously if you
want to close it you can just send it a
You can grab the code from the mercurial repository.