What's the equivalent “sizeWithFont: ” method for the Mac?

眉间皱痕 提交于 2019-12-10 03:43:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!