iOS-PingFangSC font

1. After iOS9.0, the system comes with a square font PingFangSC, but before iOS9.0, there is no square font PingFangSC. If we want to use a square font, it is good for iOS9.0 and above, but it is lower than 9.0. The font cannot be found on the system, for example:

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







Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325559287&siteId=291194637