开发者

How do you change the font of an NSTextView without changing the current content?

开发者 https://www.devze.com 2023-02-16 08:48 出处:网络
Everytime I use -setFont: or -setFont:Range: on my NSTextView, it does change the font, but it shouldn\'t. I 开发者_开发知识库just want to change the font the user is typing with.

Everytime I use -setFont: or -setFont:Range: on my NSTextView, it does change the font, but it shouldn't. I 开发者_开发知识库just want to change the font the user is typing with.

For example, if the user types 'hi' it uses the default Helvetica font. When I change the font to Times New Roman it changes that 'hi' into Times New Roman. I don't want that. I just want that, from now on, when the user types, Times New Roman is used instead of Helvetica.


I think you might want to use -[NSTextView setTypingAttributes:] instead. You should also make sure your text view is set as rich text.

0

精彩评论

暂无评论...
验证码 换一张
取 消