Jonathan Thurft
Jonathan Thurft

Reputation: 4173

How to add and use a custom font in my xcode project

I am trying to add and use a font within my app. I've followed this post for reference but I can't get it to work.

I've added the font Frutiger95UltraBlack.ttf as a supporting file and then added it to my {app-name}-Info.plist.

Then tried to use it in my app delegate to change my UINavegationBar but nothing happens.

What am i missing??

 [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                          [UIColor whiteColor], UITextAttributeTextColor,
                                                          [UIFont fontWithName:@"Frutiger95UltraBlack" size:16.0], UITextAttributeFont,nil]];

Upvotes: 1

Views: 5138

Answers (3)

MoralCode
MoralCode

Reputation: 2050

Just an FYI, UITextAttributeTextColorand UITextAttributeFont were deprecated in iOS 7.0.

Instead replace UITextAttributeTextColor with NSForegroundColorAttributeName and UITextAttributeFont with NSFontAttributeName

Upvotes: 0

Martin R
Martin R

Reputation: 540005

(From my above comment:) [UIFont fontWithName:...] requires the PostScript name of the font as parameter, that might be different from the file name.

Upvotes: 3

Ravindra Bagale
Ravindra Bagale

Reputation: 17675

make sure that your font is in your Copy Bundle Resources.

if we not adds font to target then sometimes it happens that your font not automatically adds in Copy Bundle Resources.

also make sure that your font name is same that you have used. you can make this sure by opening font in fontBook.

if you have different fonts like Regular/Bold/italic,then you have to attach this name to your font name like this-Frutiger95UltraBlack-Bold

install your font on mac system.iterate your all fonts programatically , write NSLog for fontName, by this way you can make sure the name of font i.e. PostScriptName.

Upvotes: 0

Related Questions