更改NSTextField字体大小以适应 [英] Change NSTextField font size to fit
问题描述
有什么像UILabel的> AdjustFontSizeToFitWidth
可以用于NSTextField吗?
总之:不。您必须进行一些强力工作,以确定字符串 - sizeWithAttributes: - boundingRectWithSize:options:attributes: > 我将从一个标准的系统字体大小开始,然后从那里开始向下或向上,取决于它是小于还是大于所需的矩形。 Is there anything like the UILabel's In short: no. You have to do some brute force work to determine a string's -sizeWithAttributes: -boundingRectWithSize:options:attributes: with a given font size (set as an NSFont for NSFontAttributeName). I'd start with a standard system font size and work down or up from there, depending on whether it's smaller or larger than the desired rectangle. 这篇关于更改NSTextField字体大小以适应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
adjustsFontSizeToFitWidth
that can be used with a NSTextField?