不用在infoplist里添加key直接把字体文件拖拽到项目里调用。
+(UIFont*)customFontWithPath:(NSString*)path size:(CGFloat)size
{
NSURL*fontUrl = [NSURLfileURLWithPath:path];
CGDataProviderReffontDataProvider =CGDataProviderCreateWithURL((__bridgeCFURLRef)fontUrl);
CGFontReffontRef =CGFontCreateWithDataProvider(fontDataProvider);
CGDataProviderRelease(fontDataProvider);
CTFontManagerRegisterGraphicsFont(fontRef, NULL);
NSString *fontName = CFBridgingRelease(CGFontCopyPostScriptName(fontRef));
UIFont*font = [UIFontfontWithName:fontNamesize:size];
CGFontRelease(fontRef);
returnfont;
}
网友评论