iOS 使用其他字体
1导入要用的字体 有两种方法
第一种 加入info里面 调用没起作用 不知道什么原因
我后来使用第二种方法
NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"文件名" ofType:@"otf"];
[self customFontWithPath:fontPath size:14];
-(UIFont*)customFontWithPath:(NSString*)path size:(CGFloat)size
{
NSURL *fontUrl = [NSURL fileURLWithPath:path];
CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL((__bridge CFURLRef)fontUrl);
CGFontRef fontRef = CGFontCreateWithDataProvider(fontDataProvider);
CGDataProviderRelease(fontDataProvider);
CTFontManagerRegisterGraphicsFont(fontRef, NULL);
NSString *fontName = CFBridgingRelease(CGFontCopyPostScriptName(fontRef));
UIFont *font = [UIFont fontWithName:fontName size:size];
CGFontRelease(fontRef);
return font;
}