我一直无法找到NSFont.TextStyleOptionKey
.
更具体地说,我想使用NSFont.preferredFont(forTextStyle:options:)
动态(动态点大小)类型,但我想更改字体的粗细。
我一直无法找到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