Given any arbitrary, one-line string, my goal is to render it into a bitmap representation. However, I have no means of finding out its dimensions beforehand, so I am reduced to getting the glyph range's bounding rect and resizing my canvas if it's not large enough. Unfortunately, if the canvas is not wide enough for the string, but tall enough that the text can wrap, the layout manager decides that this is best. How can I stop the layout manager from wrapping the text?
+2
A:
You should be able to use -[NSString sizeWithAttributes:]
to get a bounding box for the string with a given set of drawing attributes first, then size your view accordingly and do the actual drawing of the string.
Brian Webster
2008-10-28 19:41:17