Saturday, June 8, 2013

How To Add Custom Font Style For UILabel OR UITextViews etc In IPhone

To add custom font  in iphone for UILabel or UITextViews user following steps:

Step1: Add your custom font files into your project using Xcode as a resource


Step2: Add a key UIAppFonts in your Info.plist.

Note: Don't be confused if UIAppFonts converted into Fonts provided by application latest version of Xcode occur automatically .

Step3: Make this key as an array.

For each font you have to enter the full name of your font file (including the extension) as items to the UIAppFonts array like following image:


Step4: Save Info.plist

Step5: Now in your application you can simply call 


[UIFont fontWithName:@"CustomFontName" size:15];

 to get the custom font to use with your UILabels and UITextViews, etc…

Note: your ttf file name might not be the same name that you use when you set the font for your label (you can use the code above to get the "fontWithName" parameter).


To Check Your Custom font Is Included Or Not Use Following Code :
    for (NSString *familyName in [UIFont familyNames]) {
        for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
            NSLog(@"Font Name ->%@", fontName);
        }
    }

No comments:

Post a Comment