简体   繁体   English

fontWithName:size:如何将自己的字体导入项目?

[英]fontWithName:size: How to import own font to project?

I try to import my own font to a project and i'm stuck. 我尝试将自己的字体导入到项目中并且卡住了。 I do my research and found this but As of iOS 3.2, this functionality is built in. If you need to support pre-3.2, you can still use this solution. 我做了我的研究并发现了这个但是从iOS 3.2开始,内置了这个功能。如果你需要支持3.2之前的版本,你仍然可以使用这个解决方案。 and I create app for iOS 5.0. 我为iOS 5.0创建应用程序。

I'm try to use fontWithName:size: and docs said that The fully specified name of the font. 我尝试使用fontWithName:size:docs表示完全指定的字体名称。 This name incorporates both the font family name and the specific style information for the font. 此名称包含字体系列名称和字体的特定样式信息。 So I Put there my display name. 所以我把我的显示名称放在那里。

cell.textLabel.font = [UIFont fontWithName:@"Sansation-Light" size:10.0];

But it doesn't work. 但它不起作用。 Where do i have store this font? 我在哪里存储这个字体? In my project? 在我的项目中? is that correct name? 这个名字是正确的吗? My font name is: Sansation_Light.ttf 我的字体名称是: Sansation_Light.ttf

For This, 为了这,

  You have to add  key   "Fonts provided by application" in your info.plist .   
  for that key add  your ttf file name  for ex: "Sansation_Light.ttf" .
  it works fine for me.

It seems to be the line between Sansation and Light, it should be 这似乎是Sansation和Light之间的界限,它应该是

cell.textLabel.font = [UIFont fontWithName:@"Sansation_Light" size:10.0]; 

Or change your font name to Sansation-Light.ttf 或者将您的字体名称更改为Sansation-Light.ttf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM