IOS加载自定义的字体需要点活儿
Xcode自带字体样式查询:http://iosfonts.com/
1.下载所需要的ttf文件,导入工程中,在Info.plist
中添加一项:Fonts provided by application
,填写字体文件名称加后缀.如图:
![Info.plist配置](http://upload-images.jianshu.io/upload_images/336727-f6e55b7091388458.png?imageView2/2/w/1240/q/100)
Info.plist配置
2.前往TARGETS -> Build Phases -> Copy Bundle Resources
中添加字体文件
![Copy Bundle Resources配置](http://upload-images.jianshu.io/upload_images/336727-4e491f79e4c4b2b2.png?imageView2/2/w/1240/q/100)
Copy Bundle Resources配置
3.通过眼力找到字体文件对应的fontName
,暂未有更好的方法,如有请告知,谢谢~
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames )
{
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
for( NSString *fontName in fontNames )
{
printf( " Font: %s
", [fontName UTF8String] );
}
}
![钟齐流江毛笔草体fontName](http://upload-images.jianshu.io/upload_images/336727-40d9a17e64c1f201.png?imageView2/2/w/1240/q/100)
钟齐流江毛笔草体fontName
![蒙纳漫画体foneName](http://upload-images.jianshu.io/upload_images/336727-da04eef1eb6b0c76.png?imageView2/2/w/1240/q/100)
蒙纳漫画体foneName
4.使用自定义字体
self.Label.text = @"钟齐流江毛笔草体";
self.Label.font = [UIFont fontWithName:@"LiuJian-Mao-Cao-2.0" size:30];
self.Label2.text = @"蒙纳漫画体";
self.Label2.font = [UIFont fontWithName:@"MComicHK-Medium" size:30];
![效果图](http://upload-images.jianshu.io/upload_images/336727-aca199da35b09f02.png?imageView2/2/w/1240/q/100)
效果图
End.
文/iGeekXi(简书作者)
原文链接:http://www.jianshu.com/p/d728570bdf7b
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
原文链接:http://www.jianshu.com/p/d728570bdf7b
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。