How high and wide will NSString write?
-
10-07-2019 - |
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.
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