Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何获取NSFontManager所选字体?_Macos_Cocoa_Nsfontpanel_Nsfontmanager - Fatal编程技术网

Macos 如何获取NSFontManager所选字体?

Macos 如何获取NSFontManager所选字体?,macos,cocoa,nsfontpanel,nsfontmanager,Macos,Cocoa,Nsfontpanel,Nsfontmanager,我无法在NSFontManager中获取所选字体。我需要的是: 1)我需要获取选定的字体标题、大小、颜色? 我用如下按钮呼叫NSFontManager: [[NSFontManager sharedFontManager] orderFrontFontPanel:self]; 它正在打开,但我不知道如何选择字体作为字符串例如:Verdana 我读过苹果的文档,但我不知道如何选择字体。我不会更改或转换任何字体。我只需要知道选择了什么字体 NSString *selectedFontName =

我无法在NSFontManager中获取所选字体。我需要的是:

1)我需要获取选定的字体标题、大小、颜色?

我用如下按钮呼叫NSFontManager:

[[NSFontManager sharedFontManager] orderFrontFontPanel:self];
它正在打开,但我不知道如何选择字体作为字符串例如:Verdana

我读过苹果的文档,但我不知道如何选择字体。我不会更改或转换任何字体。我只需要知道选择了什么字体

NSString *selectedFontName = [[[NSFontManager sharedFontManager] selectedFont] displayName];

(根据您的预期用途,您可能希望使用
fontName
而不是
displayName

您是否正在使用NSFontManager的
-setTarget:
-setAction:
-selectedFont
方法?谢谢,这对我帮助很大!现在我可以得到字体名了。但是如何获得字体的颜色呢?颜色与字体无关。查看有关
NSTextView
NSTextStorage
nsattributetstring
的文档。但在顶部面板上是“文本下划线”“文本删除线”“文本颜色”这一切都用于NSTextView是吗?谢谢你提供的信息。