Say I have an array of points that form a line and a text. How can I go about drawing the text along this line in
- (void)drawRect:(CGRect)rect
of a UIView?
I am able to draw the path without a problem. Is there a standard method that I overlooked or a framework that would allow me to draw the text along that path? Ideally I would like to do this using only QuartzCore/CoreGraphics.
I tried calculating the width of each character and rotating every character. This kind of works, but I was wondering if there is a more elegant method.
I believe you can do this in Mac OS X, but the closest you’ll come on the iPhone is CGContextShowGlyphsWithAdvances and this wont even rotate.
It shouldn’t be too hard to use a loop and draw each character using something like the following. This is adapted from Apple’s documentation and not tested, so beware:
Edit: Here’s an idea of the PositionAlongPath functions. Again, they aren’t tested, but should be close. originAlong… returns (-1, -1) if you run out of path.