2013-07-20 41 views
1

我在Xcode 4.6.3中安裝自定義字體(來自Google Fonts)的問題。我做了以下內容:在Xcode 4.6.3中安裝自定義字體

  1. 下載我的字體從谷歌字體
  2. 我的Mac上安裝它,這樣我可以得到它的系統名稱
  3. 拖我的字體文件(Inconsolata.ttf)進入「支持Xcode中的文件「文件夾
  4. 轉到我的Info.Plist文件,並將Inconsolata.tff添加爲UIAppFonts陣列中的項目。
  5. 嘗試在字體列表打印出我安裝的字體使用
  6. 嘗試使用我的自定義字體,它的全名,我在Finder中發現

第5步:打印出所有UIFonts:

// When I search for "Inconsolata" in my Debug Console, it returns nothing 
// Therefore I think that the font simply isn't being installed... 
for (NSString *familyName in [UIFont familyNames]) { 
    for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) { 
     NSLog(@"%@", fontName); 
    } 
} 

第6步:使用自定義UIFont:

// this line doesn't work. 
cell.textLabel.font = [UIFont fontWithName:@"Inconsolata" size:15]; 

// this line works. it changes font to Helvetica-Bold 
// cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15]; 

回答

2

固定通過將字體文件時,像這樣

enter image description here

加入目標