简体   繁体   English

字体和字体大小更改

[英]Font and Font Size Changing

I have a Mac app with a plain-text text view. 我有一个带有纯文本视图的Mac应用程序。 I have been able to get it to save, etc, but when I change the font or font size in my app using the font panel, it is not saved when the app re-opens. 我已经能够保存它,等等,但是当我使用字体面板更改应用程序中的字体或字体大小时,重新打开应用程序时不会保存它。

How can I create a way that my app will save the font and font size changes? 如何创建我的应用保存字体和字体大小更改的方式? Thanks! 谢谢!

Save Font and Font Size in NSUserDefaults and load from NSUserDefault at the time of application launching. 在应用程序启动时,将字体和字体大小保存在NSUserDefaults中,并从NSUserDefault加载。

NSString *valueToSave = @"someValue";
[[NSUserDefaults standardUserDefaults]
    setObject:valueToSave forKey:@"preferenceName"];
to get it back later

NSString *savedValue = [[NSUserDefaults standardUserDefaults]
    stringForKey:@"preferenceName"];

Take a look at Save string to the NSUserDefaults? 看看将字符串保存到NSUserDefaults吗? post. 帖子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM