添加字体到项目当中

添加字体到项目当中

最终显示字体的效果:

步骤如下:

1. 安装字体

2. 修改plist文件  (UIAppFonts 复制粘贴)

3. 引用字体

4. 效果图

源码:

//
//  ViewController.m
//  UIFont
//
//  Created by YouXianMing on 14/12/11.
//  Copyright (c) 2014年 YouXianMing. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 设置背景色
    self.view.backgroundColor = [UIColor colorWithRed:0.176 green:0.180 blue:0.200 alpha:1];

    // 打印所有字体名字
    NSArray *familyNames = [UIFont familyNames];
    for( NSString *familyName in familyNames ){
        printf( "Family: %s \n", [familyName UTF8String] );
        NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
        for( NSString *fontName in fontNames ){
            printf( "\tFont: %s \n", [fontName UTF8String] );
        }
    }
    
    // 加载字体
    UILabel *label      = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
    label.center        = self.view.center;
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor     = [UIColor colorWithRed:0.400 green:0.141 blue:0.984 alpha:1];
    label.font          = [UIFont fontWithName:@"SentyMARUKO-Elementary" size:50.f];
    label.text          = @"YouXianMing";
    [self.view addSubview:label];
}

@end

是不是很easy:)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值