Cocoa String Pixel Length Determination (MAC OSX)

I need to figure out the NSString pixel length in Cocoa on OSX, and I found a couple of links describing how to do this using IPhone sdk, but I have not seen anything about how to do this when they are not aimed at IPhone. Can someone connect me with some documents that will be relevant. I found something in the NSString docs.

+6
string cocoa macos
source share
2 answers
+7
source share

Here is what I use to get the row size ...

NSSize size = [@"Some text" sizeWithAttributes:[NSDictionary dictionaryWithObject:[NSFont fontWithName:@"Helvetica Neue Bold" size:24.0f] forKey:NSFontAttributeName]]; 

NOTE. . If you add a line to the text box, I found that you need to add from 10 to size.width for it.

+4
source share

All Articles