Ios – Using custom fonts in interface builder

fontsinterface-builderios

I've searched this site but I just found unanswered questions.

I've loaded a custom font into my xcode project. A [UIFont fontWithName:@"Laconic-Light" size:19] works. But interface builder doesn't like the font. I can't use it with IB it always shows the default font. Is there a way to tell IB that its ok to use the font?

Best Answer

I have also this problem in Xcode 4. In my program, there are lots of UILabel which have no IBOutlets so I do in that way;

First, subclass the UILabel to CustomFontLabel

Then, override the "awakeFromNib" method

@implementation CustomFontLabel

- (void)awakeFromNib {
    [super awakeFromNib];
    self.font = [UIFont fontWithName:@"CustomFontName" size:self.font.pointSize];
}

@end

Finally, in Interface Builder > Identity Inspector change class to CustomFontLabel.