代码之家  ›  专栏  ›  技术社区  ›  BastiBen

iOS 4.2提供哪些字体?

  •  5
  • BastiBen  · 技术社区  · 15 年前

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

    不幸的是,我似乎在主文档和苹果的开发者网站上都找不到任何东西;但我隐约记得,在某个地方我看到了一个“官方”列表,也就是苹果列出了iOS上所有可用字体的列表。

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

    事先谢谢!

    更新:

    在应用商店中找到一个名为“字体”的应用程序(免费)。它只显示设备上的所有字体。

    2 回复  |  直到 12 年前
        2
  •  2
  •   Laszlo    12 年前

    - (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);
       }
    }
    

    @interface FontViewController (){
        NSArray* fontFamilies;
    }
    

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

    - (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;
    }
    

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

    here