iOS 中如何添加应用自己的字体

三步走:

第一步、往工程中拖入.ttf后缀的字体文件,字体下载地址比如:http://www.webpagepublicity.com/free-fonts.html

注意:拖入时如下图1,箭头出选中,否则不会加入Bundle中,未勾选的话可以从图2出加入:

图1:

图2:

第二步:

打开info.plist文件,加入Fonts provided by application 数组中加入下载好的字体.ttf文件,如图

第三步:使用

label.font = [UIFont fontWithName:@"Antique" size:18]
  UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 50, 200, 40)];
    label.font = [UIFont fontWithName:@"Zapfino" size:18];
    label.text = @"this is a font-style";
    [self.view addSubview:label];
    
    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 200, 40)];
    label2.font = [UIFont fontWithName:@"Antique" size:18];
    label2.text = @"this is a font-style";
    [self.view addSubview:label2];
    

    NSLog(@"%@",[UIFont familyNames]);
    for (NSString *str in [UIFont familyNames]) {
        if ([str isEqualToString:@"Antique"]) {  //检查字体是否加入
            NSLog(@"-----已加入---");
        }
    }

效果:

参考:http://blog.csdn.net/justinjing0612/article/details/8093985

原文地址:https://www.cnblogs.com/LyChen/p/5106076.html