Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone SDK 3.2 and UIAppFonts

I've added my custom font to UIAppFonts and it's loaded just fine: (shows up in [UIFont familyNames] ). When I manually set the font in viewDidLoad { [myLabel setFont: [UIFont fontWithName:@"CustomFont" size: 65.0]]; } everything works and the font is rendered.

However doing the same thing in IB doesn't (some other default font is used instead). Having to create IBOutlets for each label and fixing up the fonts manually in viewDidLoad is pretty painful.

Anyone else had problems getting the custom font support to work with 3.2 SDK and IB?

like image 618
Tarmo Avatar asked May 10 '10 12:05

Tarmo


1 Answers

Opened a bug report with Apple and turns out it really is a bug. The workaround I ended up using is this:

// LabelQuake.h
@interface LabelQuake : UILabel
@end

// LabelQuake.m
@implementation LabelQuake

    - (id)initWithCoder:(NSCoder *)decoder {
        if (self = [super initWithCoder: decoder]) {
            [self setFont: [UIFont fontWithName: @"Quake" size: self.font.pointSize]];
        }

        return self;
    }
@end

Wrote a bit longer post at our blog.

like image 74
Tarmo Avatar answered Sep 23 '22 00:09

Tarmo