We’ve got a NSString that we measure the bounding box of using - (NSSize)sizeWithAttributes:(NSDictionary *)attributes. All good.
Now we’re rotating that string using standard NSAffineTransform rotate operations – as it seems to be the only way to draw rotated NSStrings (?).
However, now the bounding box is rotated as well and we’re getting the bounds of the unrotated text using sizeWithAttributes:.
Is there a straight-forward way to get the bounding box (or dimensions) of the rotated text?
You can create a
CGRectfrom your string’s bounds and useCGRectApplyAffineTransformto get the transformed rect. It will be the smallest axis-aligned rect that contains the rotated string.