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];
  • 相关阅读:
    83. Remove Duplicates from Sorted List
    141. Linked List Cycle
    hdu1028 划分数
    XDU1019 阶乘因子的个数
    poj2773 容斥原理
    poj1091 容斥原理的应用
    poj1173 多重集组合数
    HDU 1465 错排问题
    poj 1496
    复习之求一个数的约束之积模一个质数
  • 原文地址:https://www.cnblogs.com/MrFeng/p/4977417.html
Copyright © 2011-2022 走看看