通用故事板上的自定义字体大小

时间:2015-11-25 09:48:27

标签: ios xcode swift font-size

我正在按照本教程:Font size on universal storyboard使用适用于iPad或iPhone的字体,它使用的是System字体但不使用自定义字体。这就是'正常或我还没有导入更正我的自定义字体?

捆绑资源: enter image description here

选择字体: enter image description here

下拉列表:

enter image description here

2 个答案:

答案 0 :(得分:0)

以下是使用自定义字体时常见的错误,只需执行所有步骤。

第1步:在XCode项目中包含您的字体

第2步:确保它们已包含在目标

步骤3:仔细检查您的字体是否包含在捆绑包中的资源

第4步:在应用程序plist中包含iOS自定义字体 enter image description here

步骤5:找到字体名称

在Swift中

func displayAllFont(){

    for family: String in UIFont.familyNames()
    {
        print("Family name:  \(family)")
        for names: String in UIFont.fontNamesForFamilyName(family)
        {
            print("    Font name: \(names)")
        }
    }
}

在Objective-C

NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
    NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
    fontNames = [[NSArray alloc] initWithArray:
                 [UIFont fontNamesForFamilyName:
                  [familyNames objectAtIndex:indFamily]]];
    for (indFont=0; indFont<[fontNames count]; ++indFont)
    {
        NSLog(@"    Font name: %@", [fontNames objectAtIndex:indFont]);
    }

}

答案 1 :(得分:-1)

我遇到了同样的问题并通过将label's font attributes还原为系统而不是自定义字体来解决问题

然后以编程方式将字体更改为所需的自定义字体 像这样

[[UILabel appearance] setFont:[UIFont fontWithName:@"Frutiger" size:75.0]];