Skip to content →

iPhone Custom Fonts with FontLabel

Need to use your own custom font? Or you want to support a certain font that isn’t on older iPhonts? Check out the project FontLabel.

To use FontLabel:
1. Get a copy of the project: https://github.com/zynga/FontLabel.git

2. Add the files to your project:

3. Add a font file to your project. You can find several free fonts here: http://www.webpagepublicity.com/free-fonts.html

4. In your AppDelegate, add the import:

#import “FontManager.h”

And then load the font file in the didFinishLaunchingWithOptions:

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Load Custom Fonts
[[FontManager sharedManager] loadFont:@”FuturaBoldBT”];
}

In my example, I used the font “FuturaBoldBT.ttf

5. Finally create a FontLabel, which is just a subclass of UILabel:


-(void) displayMyLabel {
FontLabel * myLabel = [[FontLabel alloc] initWithFrame:CGRectMake(10, 30, 50, 30)
fontName:@”FuturaBoldBT” pointSize:26.0f];
myLabel.textAlignment = UITextAlignmentCenter;
myLabell.textColor = UIColor.whiteColor;
[myLabel setBackgroundColor:UIColor.clearColor];
[self addSubview:myLabel];
}

Published in Code iOS