zoukankan      html  css  js  c++  java
  • iOS 自定义字体

    1.将字体文件导入工程(.ttf)

    2.打开Build Phases -> Copy Bundle Resources,确定字体文件已经添加

    3.编辑info.plist文件,添加Fonts provided by application并将字体文件加入到该项数组中

    4.使用如下代码显示所有字体名称

    //显示所有字体
    - (void)showAllFontBank{
        NSArray *familyNames =[[NSArray alloc]initWithArray:[UIFont familyNames]];
        NSArray *fontNames;
        NSInteger indFamily, indFont;
        NSLog(@"[familyNames count]===%lu",(unsigned long)[familyNames count]);
        for(indFamily=0;indFamily<[familyNames count];++indFamily){
            NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
            fontNames =[[NSArray alloc]initWithArray:[UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indFamily]]];
            for(indFont=0; indFont<[fontNames count]; ++indFont)
            {
                NSLog(@"Font name: %@",[fontNames objectAtIndex:indFont]);
            }
        }
    }

    5. 控制台输出中寻找字体名称

    6.使用UIFont调用字体

    [UIFont fontWithName:@"FZLTXHKM" size:17];
    [UIFont fontWithName:@"FZLTHJW--GB1-0" size:17];
  • 相关阅读:
    iOS中的HTTPS
    HTTPS抓包之Charles
    组件化开发的一些思考
    Xcode 调试技巧
    iOS崩溃日志分析
    iOS依赖库管理工具之Carthage
    13.类的关系总结
    12.组合(Composition)
    11.聚合(Aggregation)
    10.关联(Association)
  • 原文地址:https://www.cnblogs.com/MrFeng/p/4977417.html
Copyright © 2011-2022 走看看