简体   繁体   中英

Custom font size on universal storyboard

I was following this tutorial: Font size on universal storyboard to have an adapted font with iPad or iPhone, it's working with the System font but not with a custom font. That's it' normal or I haven't imported corrected my custom font ?

Bundle sources: 在此处输入图片说明

Choosing font: 在此处输入图片说明

dropdown list:

在此处输入图片说明

Following is the common mistake happen when using custom font just go thru all the steps.

Step 1: Include your fonts in your XCode project

Step 2: Make sure that they're included in the target

Step 3: Double check that your fonts are included as Resources in your bundle

Step 4: Include your iOS custom fonts in your application plist 在此处输入图片说明

Step 5: Find the name of the font

In Swift

func displayAllFont(){

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

In 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]);
    }

}

I had the same issue and solved it by reverting the label's font attributes to the System's instead of the Custom font

Then programmatically changed the font to the desired custom one like this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM