iOS 添加使用特殊字体

1 plist文件中添加
Fonts provided by application在这里插入图片描述
名字要对应
2 获取特殊字体使用时的实际名字
NSString *path = [[NSBundle mainBundle] pathForResource:@“IMPACT” ofType:@“TTF”];
NSURL *fontUrl = [NSURL fileURLWithPath:path];
CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL((__bridge CFURLRef)fontUrl);
CGFontRef fontRef = CGFontCreateWithDataProvider(fontDataProvider);
CGDataProviderRelease(fontDataProvider);
NSString *fontName = CFBridgingRelease(CGFontCopyPostScriptName(fontRef));

UILabel *ttttt = [[UILabel alloc] init];
ttttt.font = [UIFont fontWithName:fontName size:18];

你可能感兴趣的:(ios,特殊字体)