Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何自动更改 NSTextView 的字体大小,以使最长的段落始终不中断?NSTextView 是可调整大小的,因此字体的大小应始终更改为文本不会损坏的最大可能大小。
例如:
如果你真的想改变字体大小,我不知道有什么比-[NSAttributedString size]设置各种字体大小更好的方法。
-[NSAttributedString size]
如果您实际上并不关心 中的字体大小NSTextStorage,而只是关心它在屏幕上的显示方式,则可以将文本视图设置为不换行,然后更改其超级视图的边界以有效地“缩放”文本查看所以它的全宽总是在屏幕上。
NSTextStorage