iOS 4.2上有哪些字体?

Bas*_*Ben 5 iphone fonts ipad ios4

我正在寻找iOS 4.2上可用字体的正式列表,因为Apple在4.2更新中包含了更多字体.

不幸的是,我似乎无法在主文档中找到任何内容,也无法在Apple的开发者网站上找到任何内容; 但我依旧记得,在某个地方,我看到了一个"官方",也就是说,Apple在iOS上提供的所有字体列表.

如果有人能指出我的文档,那就太好了.:)

提前致谢!

更新:

在App Store上找到一个名为"Fonts"的应用程序(免费).它只显示设备上的所有字体.

aal*_*ano 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);
   }
}
Run Code Online (Sandbox Code Playgroud)

将其复制/粘贴到类上并使用 [self getAllFonts];

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

编辑:如果您想看看它是什么样子,我们使用表视图怎么样

第 1 步:将其添加到您的标题中

@interface FontViewController (){
    NSArray* fontFamilies;
}
Run Code Online (Sandbox Code Playgroud)

第 2 步:在界面文件 (.m) 上,在 viewDidLoad 上填充数组。

-(void)viewDidLoad{
    fontFamilies = [UIFont familyNames];
}
Run Code Online (Sandbox Code Playgroud)

STEP3:最后,将其添加到您的 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;
}
Run Code Online (Sandbox Code Playgroud)

PS:确保您已连接委托和数据源。故事板(或 xib)上的 tableView Cell 属性应该是“Cell”,并确保:

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return fontFamilies.count;
}
Run Code Online (Sandbox Code Playgroud)

有关表视图的更多信息,请查看此处的苹果文档

或者在此处查看 appCoda 的表视图教程