1. 首先下载你想要设置的字体库,例如设置方正启体简体
2. 添加到工程,一定要注意勾选红色框框处,默认是不勾选的
添加以后
3、在plist文件中添加
4、现在已经添加成功了,但是具体的FontName需要通过代码去查找。代码如下:
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
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.因为方正字体的FontName都是FZ开头,所以在打印出来的日志里面搜索FZ
方正启体简体的FontName就是FZQTJW--GB1-0,
6.字体库已经添加完毕,现在可以去使用了,例如:
self.label.font = [UIFont fontWithName:@"FZQTJW--GB1-0" size:20];