美文网首页
iOS开发—字体使用

iOS开发—字体使用

作者: Z小新 | 来源:发表于2017-03-29 13:56 被阅读160次

1.下载三方字体库,百度一大堆。
2.将字体库拖入工程
3.在修改Info.plist,添加Fonts provided by application属性(Array类型),点击+将需要添加的字体加入到该字段中。

6598283627554998743.png

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


6631290966565465635.png

4.使用字体


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


}}
Paste_Image.png

相关文章

网友评论

      本文标题:iOS开发—字体使用

      本文链接:https://www.haomeiwen.com/subject/icieottx.html