1,找到你想用的字体,导入都工程中。
2,
在工程的plist中AddRow,“Fonts provided by application” ,然后添加key为item0,value为你刚才加入的文件名。
3,这步比较麻烦,就是找到你导入的文件,用代码查找一下。
int
i = 0;
for(NSString *fontfamilyname in [UIFont familyNames])
{
NSLog(@"family:'%@'",fontfamilyname);
for(NSString *fontName in [UIFont fontNamesForFamilyName:fontfamilyname])
{
NSLog(@"\tfont:'%@'",fontName);
}
NSLog(@"-------------%d",i++);
for(NSString *fontfamilyname in [UIFont familyNames])
{
NSLog(@"family:'%@'",fontfamilyname);
for(NSString *fontName in [UIFont fontNamesForFamilyName:fontfamilyname])
{
NSLog(@"\tfont:'%@'",fontName);
}
NSLog(@"-------------%d",i++);
}
4,调用,
UILabel * tempTwoLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 40)];
UIFont * fontTwo = [UIFont fontWithName:@"Wawati SC" size:15];
[tempTwoLabel setFont:fontTwo];
[tempTwoLabel setText:@"这是新字体——ONe----->华康娃娃体"];
[self.view
addSubview:tempTwoLabel];