3

I've looked at the following link:

Setting UILabel - Font through code - generates error - iPhone

Which provides code to see all the available iOS fonts. For HelveticaNeue we get the following:

HelveticaNeue-Italic HelveticaNeue-Bold HelveticaNeue-BoldItalic HelveticaNeue

Why does Interface Builder provide a slew of other options for fonts though? I've plopped a UILabel down and I see options for HelveticaNeue-Medium and HelveticaNeue-Light for example and they seem to work fine when compiling ?

The reason I'm asking is that I'm now programmatically generating a UILabel and would like to set it's font to HelveticaNeue-Medium but it looks like that's not an option?!

Community
  • 1
  • 1
skålfyfan
  • 4,931
  • 5
  • 41
  • 59

2 Answers2

3

The Interface Builder shows all fonts available on the Mac. Not all of them are available to iOS. Before using a font, make sure that is available on iOS.

taskinoor
  • 45,586
  • 12
  • 116
  • 142
  • How then can you set a font to a UILabel in Interface Builder and have it runs perfectly on iOS both in simulator on the phone without any warnings? I'm having no issues using HelveticaNeue Medium in interface builder? Unless my app is just auto-adjusting it to HelveticaNeue ? – skålfyfan Apr 11 '11 at 20:07
  • 1
    I guess it is auto adjusting in the device. Try to use a completely different looking font which is not available in iOS. Then the effect should be clear. – taskinoor Apr 11 '11 at 20:18
2

While Interface Builder lets you pick any font, it defaults to Helvetica if the font isn't available. As far as I know, it also compiles down to Helvetica (or the system default, which apparently isn't Helvetica on iPhone 4).

Or, at least, custom fonts don't work in IB; I have to set them in -awakeFromNib or -viewDidLoad: (no, this is not a UIAppFonts problem).

tc.
  • 33,468
  • 5
  • 78
  • 96