名称和尺寸来自 NSFont
我试图在互联网上找到一些东西,但现在我没有答案,所以如果你能帮助我那就太好了! 到目前为止,我有一个 NSFont 对象,但我想要字体的名称(如 NSString)和大小,这样我就可以输出它!就像
[NSFont fontWithName:@"Menlo" size:11];
只是倒过来一样,所以我得到了名称“Menlo”和尺寸 11。
感谢帮助! 来自德国的Xcoder
i've tried to find something in the Internet, but right now I don't have an answer, so it would be great if you can help me!
So far I have a NSFont object, but I would like the name (as NSString) and size of the font, so I can output that! It's like
[NSFont fontWithName:@"Menlo" size:11];
only backwards, so I get the name "Menlo" and as size 11.
Thanks for help!
Xcoder from Germany
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为现在是 font.pointSize,而不是 font.systemSize。
I think it's font.pointSize now, not font.systemSize.
字体只是对象。它们具有诸如
fontName
和systemSize
之类的变量。例如,如果我想知道名为 titleLabel 的 UILabel 的字体和大小,我将使用:
NSLog(@"fontwithName:%@ size:%f", self.titleLabel.font.fontName, self.titleLabel.font .systemSize);
有关更多信息,请参阅 NSFont 类参考。
https://developer. apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSFont_Class/Reference/Reference.html
Fonts are just objects. They have variables like
fontName
andsystemSize
.For example if I wanted to know the font and size of a UILabel named titleLabel I would use:
NSLog(@"fontwithName:%@ size:%f", self.titleLabel.font.fontName, self.titleLabel.font.systemSize);
For more look at the NSFont Class Reference.
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSFont_Class/Reference/Reference.html
NSFont 的名称和大小是带有 setter 和 getter (
@property
) 的变量,因此您可以轻松获取它们:The name and size of NSFont are variables with setters and getters (
@property
) so you can easily get them: