- 将字体文件xx.tff拖入工程。
- 在info.plist任意键值对上按右键\Add Row,添加一个新键"Fonts provided by application",如图
- 执行下面代码获取xx.tff对应的字体族名称,字体名称。
NSArray* familys = [UIFont familyNames];
for (int i = 0; i < [familys count]; i++) {
NSString* family = [familys objectAtIndex:i];
NSLog(@”字体族名称:%@=====”, family);
NSArray* fonts = [UIFont fontNamesForFamilyName:family];
for (int j = 0; j < [fonts count]; j++) {
NSLog(@”字体名称:%@”, [fonts objectAtIndex:j]);
}
}
- 以后在代码里就可以用
xx.font = [UIFont fontWithName:@"字体名称" size:字号大小]