我感到有点震惊,我甚至要问这个问题,但是如何改变Apple watch标签的文字大小呢?它不允许在Xcode UI中更改大小,我也无法通过编程实现,而不同的字体样式甚至无法改变大小。
我感到有点震惊,我甚至要问这个问题,但是如何改变Apple watch标签的文字大小呢?它不允许在Xcode UI中更改大小,我也无法通过编程实现,而不同的字体样式甚至无法改变大小。
要更改字体,您不能使用主模板(文本样式-正文)。您应将其更改为“系统”,然后尝试更改字体大小:
lblSomething.setAttributedText(NSAttributedString(string: "Text Here", attributes: [NSFontAttributeName: UIFont.systemFontOfSize(20.0, weight: UIFontWeightBold)]))
注意事项
1- 请使用自己的字体大小,而不是20.0。
2- 你可以使用以下其中一个代替UIFontWeightBold
:
3- 请使用自己的文本内容,而不是“Text Here”。
4- 请使用自己的标签名称,而不是lblSomething
。
您可以通过使用NSAttributedString
编程实现此目的:
let font = UIFont.systemFontOfSize(32.0, weight: UIFontWeightMedium)
let attrStr = NSAttributedString(string: "Some String", attributes: [NSFontAttributeName: font])
label.setAttributedText(attrStr)
UIFontWeightBold
etc. has been renamed toUIFont.Weight.bold
or just.bold
- John Morris