什么是等效的"sizeWithFont:" Mac的方法? [英] What's the equivalent "sizeWithFont: " method for the Mac?

查看:104
本文介绍了什么是等效的"sizeWithFont:" Mac的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对iPhone的sizeWithFont:很熟悉.现在,我正在尝试为Mac构建一个应用程序,并且需要类似的东西,但是我不知道该怎么做:/

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 :/

这就是我需要它的原因:我有一个显示一些文本的面板,我想调整它的大小以使其恰好适合内容(NSTextView).你会怎么做?

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?

推荐答案

看看NSString的sizeWithAttributes:.您必须创建一个属性字典;看看 Apple的文档.

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.

这篇关于什么是等效的"sizeWithFont:" Mac的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆