1.导入 xx.ttf文件到工程目录下
2. Build Phases ->Copy Bundle Resources 加入xx.ttf文件
3.配置文件加入Fonts provided by application 设置
4.遍历查找所有支持的字体 从中找到需要的 使用familyName
NSArray *familyNames =[[NSArray alloc]initWithArray:[UIFont familyNames]];
for(NSInteger i = 0;i < familyNames.count;i++ ){
NSLog(@"Family name: %@", familyNames[i]);
NSArray *fontNames =[[NSArray alloc] initWithArray:[UIFont fontNamesForFamilyName:familyNames[i]]];
for(NSInteger m = 0; m <fontNames.count; m++ ) {
NSLog(@"Font name: %@",fontNames[m]);
}
}
eg:
label.font = [UIFont fontWithName:@"DINPro-Medium" size:17];