標籤: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:)
添加字型到項目當中