Question

How do I work out how much large an area drawing an NSString will occupy, i.e. by using:

[string drawAtPoint:p withAttributes:nil];      

I ideally need to work this out before its drawn so I can space out the "areas" in which the strings are drawn appropriately.

Was it helpful?

Solution

You can use the -[NSString sizeWithAttributes:] message.

OTHER TIPS

You can use sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode:. It's an addition to NSString provided by UIKit (look for "NSString UIKit Additions Reference" in the docs).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top