如何将菜单项中的比例数字更改为表格数字?
Howto change from proportional to tabulated digits in menu items?
我想将菜单项中的比例数字改为表格数字?可能吗?
Menu without tabulated digits
您需要像这样使用等宽字体:
label.font = UIFont.monospacedDigitSystemFont(ofSize: 17, weight: UIFontWeightRegular)
显然,您可以指定所需的任何字体大小和粗细(或从当前字体描述符中获取它们)。
您可以设置attributedTitle
property of a NSMenuItem
and provide whatever custom alignment or formatting you want through an NSAttributedString
可以在此处查看有关如何在属性字符串中进行字符串对齐的好示例:
Attributed Text Center Alignment
这是一个说明如何向属性字符串添加制表位的答案:
How do I add tab stops to an NSAttributedString
您甚至可以从 RTF 或 HTML:
创建属性字符串
我想将菜单项中的比例数字改为表格数字?可能吗?
Menu without tabulated digits
您需要像这样使用等宽字体:
label.font = UIFont.monospacedDigitSystemFont(ofSize: 17, weight: UIFontWeightRegular)
显然,您可以指定所需的任何字体大小和粗细(或从当前字体描述符中获取它们)。
您可以设置attributedTitle
property of a NSMenuItem
and provide whatever custom alignment or formatting you want through an NSAttributedString
可以在此处查看有关如何在属性字符串中进行字符串对齐的好示例:
Attributed Text Center Alignment
这是一个说明如何向属性字符串添加制表位的答案:
How do I add tab stops to an NSAttributedString
您甚至可以从 RTF 或 HTML:
创建属性字符串