添加字型到項目當中

來源:互聯網
上載者:User

標籤:style   blog   http   io   ar   color   sp   for   on   

添加字型到項目當中

最終顯示字型的效果:

步驟如下:

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:)

添加字型到項目當中

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.