Reputation: 8035
I am using some custom fonts in my iphone app. They are displayed correctly, but i cant change their size.
Here is how set this font for UILabel:
myLabel.font=[UIFont fontWithName:@"Cabin-Regular" size:18];
This label is part of uitableview cell, if that could play any role.
Label settings in IB:
I change only color, text and font in code for this label.
What could be wrong?
Upvotes: 3
Views: 1974
Reputation: 6413
You need to add your font in your Xcode
, if you are adding manually.
Project name-Info.plist
file, right click and click Add Row
.Fonts provided by application
. If you expand it you can add new items, in there add value to item 0
. The value should be your font
file name. like below image
4. Double click on your font, it'll open in external editor, like following image
5.Give that name into your fontWithName:
method. If you are setting value to your tableviewcell
. the code will be
cell.nameLbl.font = [UIFont fontWithName:@"Cabin" size:18.0];
It works fine for me. I hope it helps :)
Upvotes: 2
Reputation: 697
Are you sure the font is loaded correctly?
You can try:
for (NSString *familyName in [UIFont familyNames]) {
NSLog(@"%@", familyName);
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(@"\t%@",fontName);
}
}
This will show you all the fonts that are loaded. Make sure the same name "Cabin-Regular" is showing up exactly the same. A lot of times the font itself isn't loaded and then the font-size won't be used at all.
Upvotes: 4