问题
I followed the steps outlined in various locations using the UIAppFonts
property list key. I'm using the Aller Light font. I've added it as a resource, added the font name correctly in the info property list, and am now attempting to use it, however every attempt to do so results in the default font being displayed. So far I've tried:
[leader setFont:[UIFont fontWithName:@"Aller Light" size:20.0]];
[leader setFont:[UIFont fontWithName:@"AllerLight" size:20.0]];
[leader setFont:[UIFont fontWithName:@"Aller-Light" size:20.0]];
[leader setFont:[UIFont fontWithName:@"Aller-Lt.ttf" size:20.0]];
leader.font = [UIFont fontWithName:@"Aller Light" size:20.0];
... with all the variants listed above
None of them work. Running NSLog(@"Available fonts: %@", [UIFont familyNames]);
returns:
Available fonts: (
...
"Aller Light",
...
)
Thoughts or solutions? Installing the font on my mac and looking in Font Book, the name of the font is Aller Light. Verifying the font in Font Book indicates that the font name is in fact simply Aller Light.
回答1:
List all fonts
for (NSString *name in [UIFont familyNames]) {
NSLog(@"Family name : %@", name);
for (NSString *font in [UIFont fontNamesForFamilyName:name]) {
NSLog(@"Font name : %@", font);
}
}
来源:https://stackoverflow.com/questions/9750222/issues-with-custom-font-in-ios