iphone - iOS 4.2 上有哪些字体可用?

标签 iphone ipad fonts ios4

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

不幸的是,我似乎在主要文档中找不到任何内容,在苹果的开发者网站上也找不到任何内容;但我依稀记得在某处看到过一个“官方”,即Apple制作的iOS上所有可用字体的列表。

如果有人能给我指出一份文档,那就太好了。 :)

提前致谢!

更新:

在 App Store 上找到了一款名为“Fonts”的应用程序(免费)。它只是显示设备上的所有字体。

最佳答案

您可以使用此方法检查您的设备(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];

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

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

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

@interface FontViewController (){
    NSArray* fontFamilies;
}

第 2 步:在界面文件 (.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;
}

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

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

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

有关表格 View 的更多信息,请查看苹果文档 here

或者查看appCoda的Table View教程here

关于iphone - iOS 4.2 上有哪些字体可用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4223689/

相关文章:

css - 字体被 firefox 和 chrome 侵 eclipse

iphone - 如何将一个 NSMutableArray 中的最后三 block 数据复制到另一个 NSMutableArray 中?

iphone - 覆盖 "Structured Glas"对 iPhone 相机源的影响 - 一般说明

iphone - 以横向和纵向模式制作 APP 的最佳方式

ios - iOS/移动版 safari 与现代浏览器标准的符合程度如何?

opengl - 用opengl写阿拉伯语文本

iphone - 为什么我无法执行任何 CABasicAnimation 或关键帧动画内容?

ios - 为 iPad 添加第二个启动画面

iphone - 启动图像 - iPhone 应用程序

css - @font-face 远程字体的模糊/粗体/扭曲字形