Leon
Leon

Reputation: 417

font changing doesn't work

i want to change the font of a label from helvetica to calibri bold. so i chose calibri bold in the interface builder, but on my iphone it's sill helvetica. when i try to change it in the code like:

[label setFont: [UIFont fontWithName: @"Calibri Bold" size: 48.0]];
label.textColor = [UIColor whiteColor];

the font on my iphone is helvetica 12.

where is the mistake?

thank you :)

Upvotes: 0

Views: 2093

Answers (3)

Yuras
Yuras

Reputation: 13876

Are you sure the font is available on iPhone?

Here is a list of available fonts (maybe out of date, but...)

Upvotes: 0

mvds
mvds

Reputation: 47114

The mistake is that the Calibri Bold font is not part of iOS.

You can supply it as a custom font, as a resource. Don't forget to add the relevant keys to the info.plist. It should be UIAppFonts, type array, containing the file names of the fonts. Then get the font name using [UIFont familyNames] - it may not match the file name.

Upvotes: 3

Bogatyr
Bogatyr

Reputation: 19343

Three things: 1) not every font in interface builder is available on the iphone 2) You have to choose the name which matches exactly the internal name for the font -- this is often not the IB "regular" name of the font. 3) make sure your outlets are correctly connected otherwise your code will not change the label.

Here's a link to the internal font names on the iphone: (kind of out of date but you can run his same code in your project to get the up to date list of names):

http://ajnaware.wordpress.com/2008/10/24/list-of-fonts-available-on-the-iphone/

Upvotes: 0

Related Questions