iOS 4.2 上有哪些可用的字体?

5
我正在寻找iOS 4.2上可用字体的官方列表,因为苹果在4.2更新中增加了更多字体。
不幸的是,我似乎在主要文档中和苹果的开发者网站上都找不到任何东西;但我依稀记得在某个地方看到过一个“官方”的iOS所有可用字体列表,这是由苹果制作的列表。
如果有人能指向一份文件,那就太好了。:)
提前感谢!
更新:
在App Store上找到了一个名为“Fonts”的应用程序(免费)。它简单地显示设备上的所有字体。

2
可能是什么字体支持iPhone应用程序?的重复问题。 - Brad Larson
1个回答

2
您可以使用以下方法检查您的设备(iPhone或iPad)可用的字体:
- (void)getAllFonts{
   NSArray *fontFamilies =[UIFont familyNames];

   for(int i =0; i <[fontFamilies count]; i++){
       NSString *fontFamily =[fontFamilies objectAtIndex:i];
       NSArray *fontNames =[UIFont fontNamesForFamilyName:[fontFamilies objectAtIndex:i]];
       NSLog(@"%@: %@", fontFamily, fontNames);
   }
}

将以下内容复制/粘贴到类中,并使用[self getAllFonts];

该列表应显示在您的日志中

编辑:如果您想查看它的外观,我们如何使用表视图

步骤1:将以下内容添加到您的标题中

@interface FontViewController (){
    NSArray* fontFamilies;
}

第二步:在您的接口文件(.m)中,在viewDidLoad中填充您的数组。

-(void)viewDidLoad{
    fontFamilies = [UIFont familyNames];
}

步骤三:最后,将此添加到你的cellForRowAtIndexPath方法中

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    // The Magic :)    
    cell.textLabel.text = [fontFamilies objectAtIndex:indexPath.row];
    cell.textLabel.font = [UIFont fontWithName:[fontFamilies objectAtIndex:indexPath.row] size:12];

    return cell;
}

注意:确保您已连接委托和数据源。您在故事板(或xib)上的tableView单元格属性应为“Cell”,并确保:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return fontFamilies.count;
}

要了解有关表视图的更多信息,请查看苹果文档 这里

或者查看appCoda的表视图教程 这里


谢谢,虽然你无法以这种方式看到字体的样式。 - BastiBen
抱歉,我编辑了一下。帖子有点长,但这样可以让你看到每种字体的效果 :) 祝好 - aalesano

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接