如何解决NSFont.TextStyleOptionKey 中可以使用哪些值
我找不到 NSFont.TextStyleOptionKey
的有效值。
更具体地说,我想使用 NSFont.preferredFont(forTextStyle:options:)
来获得动态(动态点大小)类型,但我想更改字体的粗细。
解决方法
这些值由 XCode 中的自动完成显示:
NSFont.Weight.black
NSFont.Weight.heavy
NSFont.Weight.bold
NSFont.Weight.semibold
NSFont.Weight.medium
NSFont.Weight.regular
NSFont.Weight.light
NSFont.Weight.thin
NSFont.Weight.ultraLight
jump to definition
命令显示了这一点:
extension NSFont.Weight {
@available(macOS 10.11,*)
public static let ultraLight: NSFont.Weight
@available(macOS 10.11,*)
public static let thin: NSFont.Weight
@available(macOS 10.11,*)
public static let light: NSFont.Weight
@available(macOS 10.11,*)
public static let regular: NSFont.Weight
@available(macOS 10.11,*)
public static let medium: NSFont.Weight
@available(macOS 10.11,*)
public static let semibold: NSFont.Weight
@available(macOS 10.11,*)
public static let bold: NSFont.Weight
@available(macOS 10.11,*)
public static let heavy: NSFont.Weight
@available(macOS 10.11,*)
public static let black: NSFont.Weight
}
其他选项可以在文档中找到:https://developer.apple.com/documentation/appkit/nsfont/textstyleoptionkey
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。