问题
I'm familiar with sizeWithFont:
for the iPhone. Now I'm trying to build an app for the Mac and need something like that, but I don't know how to do it :/
Here's why I need it: I've got a panel that displays some text, and I want to size it so that it just fits the content (a NSTextView
). How would you do it?
回答1:
Take a look at NSString's sizeWithAttributes:
. You'll have to create a dictionary of attributes; take a look at Apple's documentation for that.
来源:https://stackoverflow.com/questions/2349692/whats-the-equivalent-sizewithfont-method-for-the-mac