0

I followed this step by step and successfully added a custom font in my project, I am able to change the font of my textView by setting my textView's font attribute programmatically.

In interface builder, I can also set the custom font using the font picker for my textView, and I can see that the font is applied to the textView in interface builder.

The problem is if I remove the code that sets the font, then the font on real device is still the system font despite that I already set the font in interface builder.

So how can I set the custom font in interface builder and make it work, without having to set the font in code?

axl411
  • 920
  • 1
  • 7
  • 23

3 Answers3

2

Go to Build Phases --> Copy Bundle resources

see Your custom font file is there or not .

It is not there then click on + sign and add it .

Before that check that you add font file in your project .

also check whether it is set in .plist file or not

MAC113
  • 1,444
  • 12
  • 19
  • Those have all been done (I can use the custom font on device if I set it in code). According to @Pallavi Ligade, the custom fonts that displayed in interface builder will not get applied at run time, so I still need to apply the custom font in code. – axl411 Feb 02 '15 at 15:28
2

I had the same problem, I deleted the fonts from my app and put them back by using group creation and not folder reference, so my fonts appeared in "Copy Bundle Resources". Now it's working perfectly.

Thib L
  • 704
  • 1
  • 8
  • 20
1

Steps which are done for Font is correct, but as per my understanding 2 things are there first is Xcode displays fonts which are found in the Mac OS or in your system, not on the actual iOS device. Before selecting a font, you should make sure it is available on iOS devices. and second is when we edit text in xib,custom Fonts appear, but at runtime it will not get applied. So it is better that you apply font pragmatically.
http://iosfonts.com/ , http://support.apple.com/en-in/HT202771 or even trial and error can help.

Pallavi Ligade
  • 529
  • 3
  • 14
  • So I still need to apply the font in code. This makes it a little cumbersome if I have many labels that need to have custom font. I'll have to make many outlets. Or I can make a subclass of `UILabel` and apply the font at init time. Why does Apple not allow setting custom font using interface builder directly? – axl411 Feb 02 '15 at 15:33
  • For ur ref chk this link http://stackoverflow.com/q/22035985/3481145 , but I think u have done all this. If still not work then make custom class of UILabel. – Pallavi Ligade Feb 02 '15 at 16:10