I am unable to set custom font for the UILabel in XCode.
This is what I've tried:
Download "JennaSue" font -- http://www.dafont.com/jenna-sue.font
Open "app-info.plist" under "Supporting Files" folder
Add new row in the list with key "Fonts provided by application"
In this array add "JennaSue.ttf"
Use it in the code like this:
self.someLabel.font = [UIFont fontWithName:@"JennaSue" size:14];
And nothing happens -- the default font is visible.
Why? What am I doing wrong? How can I fix it?
Here is @Ritu's answer in Swift 2. Just put this in your AppDelegate, or in viewDidLoad method of your View Controller:
You will have all your font names in console log, just copy and paste the one you need in your code.
is the file visible in Compile Source now…if yes then you may have the font name wrong..sometimes the font names are different then their file name…try running a
this lines of code..you will be able to see the actual name of the font and use that name instead
After adding custom font to Xcode don't forget to add font to plist.
Project settings
>Info
>Custom IOS target properties
Add property
Fonts provided by application
and type your custom font(filename of font file). Then you can use that code exampleself.someLabel.font = [UIFont fontWithName:@"JennaSue" size:14];
Notice: make sure that you use right font name in code. To do that you should add this font to your Mac's font book, open font book, choose that font and check the right name font.
Hope this helps
Be sure your font is in Bundle Resources. For some reason Xcode it is not importing custom font properly most of the time:
I've got the font working:
Example code: here
Check this code:
and use the same name printed with NSLog.
info.plist
file,Add row
,Fonts provided by application
in the new row,someLabel.font = [UIFont fontWithName:@"JennaSue" size: 12.0];
I think you've missed step 5 up there.
Update: When doing step 5, remember to check the marks for copying the actual file into project directory:
Remember to clean your project by pressing "command+alt+shift+K" (IRRC!) And then go to your
and then go to your project's Build Phases, and make sure you can see your
.ttf
file file among the resource files:P.S. I'm not on my Mac at the moment, so I used screenshots from this tutorial. That's why I grayed out the unnecessary lines for your issue.