Steaphann
Steaphann

Reputation: 2777

Can't set custom font on my UILabels

I am trying to set a custom font on my UILabels

Now I have added the font to my Plist with the name Lucida-Sans-Unicode.ttf. I've added the '-' because I read somewhere that the spaces maybe can cause the problem. I also changed the name of the font to the name with the '-' in it.

Finally on my Label I call the font like this.

[UIFont fontWithName:@"LucidaSans-Typewriter" size:12.0f]

But still the font has not been set correctly. Can someone help me ?

Kind regards

Upvotes: 2

Views: 1050

Answers (2)

Paras Joshi
Paras Joshi

Reputation: 20541

First check it out that you give outlet to that UILabel correctly and then use bellow code..

UIFont *myFont = [UIFont fontWithName:@"Helvetica-BoldOblique" size:20];
[yourLable setFont:myFont];

here if you used LucidaSans font then first check that this font available in your system or not then try with bellow code..

UIFont *myFont = [UIFont fontWithName:@"LucidaSans-Typewriter" size:12.0f];
[yourLable setFont:myFont];

Upvotes: 2

SAMIR RATHOD
SAMIR RATHOD

Reputation: 3510

Here are the steps transcribed:

1) Add your custom font files into your project using Xcode as a resource
2) Add a key to your Info.plist file called Fonts provided by application.
3) Make this key an array
4) For each font you have, enter the full name of your font file (including the extension) as items to the Fonts provided by application array
5) Save Info.plist
Now in your application you can simply call

 [myLabel setFont:[UIFont fontWithName:@"Swis721 Lt BT" size:[lbl minimumFontSize]]]; //use font name not file name.

no need to added the '-' because it doesn't meter.

Upvotes: 5

Related Questions