项目中需要使用第三方的字体FZLTCXHJW.TTF,添加步骤如下:
1、将FZLTCXHJW.TTF字体库添加到工程里面
2、在工程的Info.plist中添加一行Fonts provided by application。加上字体库的名称如图:
3、引用字体库的名称,设置字体:[UIFont fontWithName:@"fontName" size:16];
UILabel * tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, 300, 40)];
tempLabel.font = [UIFont fontWithName:@"FZLanTingHeiS-UL-GB" size:40];
tempTwoLabel.text = @"新的字体:兰亭超细字体";
[self.view addSubview:tempTwoLabel];
备注:如果不知道字体的名称,可以遍历字体进行查找:
for(NSString *fontfamily in [UIFont familyNames])
{
NSLog(@"family:'%@'",fontfamily);
for(NSString *fontName in [UIFontfontNamesForFamilyName:fontfamily])
{
NSLog(@"fontName:'%@'",fontName);
}
}