gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 18:57:56 25 4
gpt4 key购买 nike

我正在寻找 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com