UIFont *font = [ UIFontfontWithName:@"PingFangSC-Regular"size:18];
2. The font we get is nil, so we need to manually import third-party fonts, so I can judge in the project;
UIFont *font = [ UIFontfontWithName:@"PingFangSC-Regular"size : 18 ]; // This is the square font that comes after 9.0
if(font==nil){
// This is a third-party square font that I manually imported
font = [ UIFontfontWithName:@"PingFang-SC-Regular"size:18];
}
3. We can print all the fonts in the project, including the third-party fonts we manually imported;
<span style="font-size:18px;"> for(NSString *fontfamilyname in [UIFont familyNames]) { NSLog(@"family:'%@'",fontfamilyname); for(NSString *fontName in [UIFont fontNamesForFamilyName:fontfamilyname]) { NSLog(@"\tfont:'%@'",fontName); } NSLog(@"-------------"); } </span>For example, to print the square font that comes with iOS9.0:
Method name :-[ZHBlurtView setupContentView:number:fansNumber:] Line number : 198Content :font:'PingFangSC-Ultralight'
Method name :-[ZHBlurtView setupContentView:number:fansNumber:] Line number : 198Content :font:'PingFangSC-Regular'
Method name :-[ZHBlurtView setupContentView:number:fansNumber:] Line number : 198Content :font:'PingFangSC-Semibold'
Method name :-[ZHBlurtView setupContentView:number:fansNumber:] Line number : 198Content :font:'PingFangSC-Thin'
Method name :-[ZHBlurtView setupContentView:number:fansNumber:] Line number : 198Content :font:'PingFangSC-Light'
Method name :-[ZHBlurtView setupContentView:number:fansNumber:] Line number : 198Content :font:'PingFangSC-Medium'
For example, the square font I manually imported to print:
Method Name : -[BaseViewController viewDidLoad] Lines : 29 Contents :font:'.PingFang-SC-Thin'
Method Name : -[BaseViewController viewDidLoad] Lines : 29 Contents :font:'PingFang-SC-Regular'
Method Name : -[BaseViewController viewDidLoad] Lines : 29 Contents :font:'.PingFang-SC-Medium'
Method Name : -[BaseViewController viewDidLoad] Lines : 29 Contents :font:'PingFangSC-Light'
Method Name : -[BaseViewController viewDidLoad] Lines : 29 Contents :font:'PingFangSC'
Method Name : -[BaseViewController viewDidLoad] Lines : 29 Contents :font:'PingFangSC-Medium'
Notes:
1. Font download address: http://download.csdn.net/detail/u014220518/9524884
2. Import third-party font process: http://jingyan.baidu.com/article/4853e1e51e72111909f726f9.html