IOS 使用自定义字体

1、确定你的项目工程的Resources下有你要用的字体文件(.ttf或者.odf)。 

2、然后在你的工程的Info.plist文件中新建一行,添加key为:UIAppFonts,类型为Array或Dictionary都行,在UIAppFonts下再建立一个键值对,key为:Item 0,添加Value为XXX.ttf(字体的名字,string型),可以添加多个,使用的时候写对应字体名字就行。

3、在你的项目里要用字体的时候 xx.font = [UIFont fontWithName:@"XXX" size:20.0],这样就可以了。

例子

- (void)viewDidLoad {  

  •     NSString *imageName = @"grid.png";  
  •     UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];  
  •     imageView.frame = CGRectMake(20, 20, 250, 250);  
  •       
  •     UILabel *test = [[UILabel alloc] init];  
  •     test.frame = CGRectMake(95, 215, 200, 50);  
  •     test.font=[UIFont fontWithName:@"HAKUYOGuiFanZi3500" size:30];  
  •     test.text = @"原始图片";  
  •     test.backgroundColor = [UIColor clearColor];  
  •     [imageView addSubview:test];  
  •     [test release];  
  •       
  •     [self.view addSubview:imageView];  
  •     [imageView release];      
  • }  
原文地址:https://www.cnblogs.com/zhibin/p/4119089.html