1.下載三方字體庫,百度一大堆。
2.將字體庫拖入工程
3.在修改Info.plist,添加Fonts provided by application屬性(Array類型)埠褪,點(diǎn)擊+將需要添加的字體加入到該字段中。
4.修改工程配置,加入字體庫
4.使用字體
代碼創(chuàng)建 Lable
UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:view];
UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, 100)];
lable.font = [UIFont fontWithName:@"STXingkai" size:60];
lable.text = @"華文行楷";
[lable sizeToFit];
[view addSubview:lable];
遍歷字體庫 组橄,查詢字體名稱
// 遍歷字體
for (NSString *fontFamilyName in [UIFont familyNames]) {
NSLog(@"family:'%@'",fontFamilyName);
for(NSString *fontName in [UIFont fontNamesForFamilyName:fontFamilyName]) {
NSLog(@"\t font:'%@'",fontName);
}
NSLog(@"---------------------------------------------");
}}