简体   繁体   中英

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. and I create app for iOS 5.0.

I'm try to use fontWithName:size: and docs said that The fully specified name of the font. 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

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

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

Or change your font name to Sansation-Light.ttf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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