iOS开发—字体使用
2017-03-29 本文已影响160人
Z小新
1.下载三方字体库,百度一大堆。
2.将字体库拖入工程
3.在修改Info.plist,添加Fonts provided by application属性(Array类型),点击+将需要添加的字体加入到该字段中。

4.修改工程配置,加入字体库

4.使用字体

代码创建 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(@"---------------------------------------------");
}}
