iOS 设备上的字体 [英] Fonts on iOS device

查看:20
本文介绍了iOS 设备上的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过 [UIFont familyNames],但我在不同的设备上有各种列表(但使用相同的 iOS 版本).谁能告诉我,上述方法列出的字体是否包括其他已安装应用程序提供的自定义字体,或者这些只是iOS附带的字体?

I've read the available font families by [UIFont familyNames], but I've got various lists on different devices (but with the same iOS version). Can somebody tell me, if the fonts listed with the method above, are including custom fonts provided by other installed applications or if those are only the fonts shipped with iOS?

推荐答案

是的,它会显示您应用中的所有字体,包括您添加的自定义字体.这是列出所有字体的较短代码:

Yes, it shows all the fonts within your app, including the custom fonts you've added. Here's the shorter code to list all the fonts:

for (NSString *familyName in [UIFont familyNames]){
    NSLog(@"Family name: %@", familyName);
    for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
        NSLog(@"--Font name: %@", fontName);
    }
}

斯威夫特 2

for familyName:AnyObject in UIFont.familyNames() {
    print("Family Name: (familyName)")
    for fontName:AnyObject in UIFont.fontNamesForFamilyName(familyName as! String) {
        print("--Font Name: (fontName)")
    }
}

斯威夫特 3

 for familyName:String in UIFont.familyNames {
     print("Family Name: (familyName)")
     for fontName:String in UIFont.fontNames(forFamilyName: familyName) {
         print("--Font Name: (fontName)")
     }
 }

这篇关于iOS 设备上的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆