如何自动更改 NSTextView 的字体大小以使最长的段落始终不被破坏?
如何自动更改 NSTextView 的字体大小,以便最长的段落始终不被破坏? NSTextView 是可调整大小的,因此字体大小应始终更改为文本不被破坏的最大可能大小。
例如:
How can I change the font size of an NSTextView automatically so that the longest paragraph is always not broken? The NSTextView is resizable, so the size of the font should always change to the maximal possible size in which the text is not broken.
For example:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您确实想更改字体大小,我不知道有什么比调用
-[NSAttributedString size]
并设置各种字体大小更好的方法。如果您实际上并不关心 NSTextStorage 中的字体大小,而只是关心它在屏幕上的显示方式,那么您可以将文本视图设置为不换行,然后更改其边界superview 有效地“缩放”文本视图,使其完整宽度始终显示在屏幕上。
If you actually want to change the font size, I don't know of a better way than to call
-[NSAttributedString size]
with various font sizes set on it.If you don't actually care about the font size in the
NSTextStorage
, but just about how it appears on screen, you might be able to set the text view to not wrap and then change the bounds of its superview to effectively "zoom" the text view so its full width is always on screen.