标签:
1.将字体文件导入工程(.ttf)
2.打开Build Phases -> Copy Bundle Resources,确定字体文件已经添加
3.编辑info.plist文件,添加Fonts provided by application并将字体文件加入到该项数组中
4.使用如下代码显示所有字体名称
//显示所有字体 - (void)showAllFontBank{ NSArray *familyNames =[[NSArray alloc]initWithArray:[UIFont familyNames]]; NSArray *fontNames; NSInteger indFamily, indFont; NSLog(@"[familyNames count]===%lu",(unsigned long)[familyNames count]); for(indFamily=0;indFamily<[familyNames count];++indFamily){ NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]); fontNames =[[NSArray alloc]initWithArray:[UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indFamily]]]; for(indFont=0; indFont<[fontNames count]; ++indFont) { NSLog(@"Font name: %@",[fontNames objectAtIndex:indFont]); } } }
5. 控制台输出中寻找字体名称
6.使用UIFont调用字体
[UIFont fontWithName:@"FZLTXHKM" size:17]; [UIFont fontWithName:@"FZLTHJW--GB1-0" size:17];
标签:
原文地址:http://www.cnblogs.com/MrFeng/p/4977417.html