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?!
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.
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).
精彩评论