Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Designing labels/text views with custom fonts in Interface Builder

I am currently working on an iPhone project in which all labels/text views etc. should appear with a custom font (I'm using Xcode 4.2.1). I have done some research on this, and the only solution seems to be adding the font files to the project, editing the info.plist file appropriately and setting the font programmatically (i.e. by outlets or by subclassing the relevant views). In any case, these approaches won't lead to the interface builder displaying the text with the custom font (it will still show Helvetica). It is not possible to select the custom font using the attributes inspector.

Although I don't think I missed something, I just want to make sure there is no other way than programmatically setting the fonts, which would be a rather painful for the task I have to work on (localization issues, unique app design etc.). It would be nice to get the interface builder to display custom fonts..

like image 845
bompf Avatar asked Mar 13 '12 12:03

bompf


2 Answers

Custom fonts can only be set programmatically..Unfortunately..this is termed as a bug in interface builder and hasn't been fixed yet.

like image 109
Shubhank Avatar answered Sep 24 '22 05:09

Shubhank


using custom fonts in Interface Builder a reusable library is available.

It uses a simple trick for doing this. Set the font(say calibri) to all of your UI Elements that you will never use in your project and FontReplacer will do mapping between custom font and calibri. So there is no need to make IBOutlets or any other graphics.

Here is link to github from where you can download FontReplacer to use in your project. https://github.com/0xced/FontReplacer

another question is addressing same Fonts not displaying in Interface Builder i have also posted possible solution there

like image 31
abdus.me Avatar answered Sep 21 '22 05:09

abdus.me