11

I'm kind of stunned I even have to ask this question, but how is it possible to change the size of a label's text on the Apple watch? It doesn't allow changing the size in the Xcode UI, I haven't been able to do it programmatically, and the different font styles don't even change the size.

123
  • 8,733
  • 14
  • 57
  • 99

2 Answers2

17

With UI

To change the font, you can't use the main template (Text Styles - Body). You should change it to "System", and then try to change font size:

enter image description here

enter image description here

With Code

lblSomething.setAttributedText(NSAttributedString(string: "Text Here", attributes: [NSFontAttributeName: UIFont.systemFontOfSize(20.0, weight: UIFontWeightBold)]))

Notes

1- Instead of 20.0, you should use your own font size.

2- Instead of UIFontWeightBold, you could use one of the following:

enter image description here

3- Instead of "Text Here", use your own text.

4- Instead of lblSomething, use your label name.

Seyed Parsa Neshaei
  • 3,470
  • 18
  • 30
  • `UIFontWeightBold` etc. has been renamed to `UIFont.Weight.bold` or just `.bold` – John Morris Jan 27 '18 at 15:14
  • Hi, Im looking for a way to change the weight without changing the size so it works on all Apple Watch sizes. I set the size in the interface builder. – Kurt L. Jan 16 '20 at 22:05
4

You can achieve this programmatically with a NSAttributedString:

let font = UIFont.systemFontOfSize(32.0, weight: UIFontWeightMedium)
let attrStr = NSAttributedString(string: "Some String", attributes: [NSFontAttributeName: font])
label.setAttributedText(attrStr)
Daniel Storm
  • 18,301
  • 9
  • 84
  • 152