IOS加载自定义的字体需要点活儿
Xcode自带字体样式查询:http://iosfonts.com/
1.下载所需要的ttf文件,导入工程中,在Info.plist
中添加一项:Fonts provided by application
,填写字体文件名称加后缀.如图:
2.前往
TARGETS -> Build Phases -> Copy Bundle Resources
中添加字体文件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( "\tFont: %s \n", [fontName UTF8String] );
}
}
钟齐流江毛笔草体fontName
蒙纳漫画体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];
效果图
End.
网友评论