orak
orak

Reputation: 2419

How to use custom font without size?

I want to use a custom font in whole app (ios 5). I used the following code

[[UILabel appearance] setFont:[UIFont fontWithName:@"MyCustomFont" size:17.0]];

The problem with this is that it overrides all font sizes in all views.

How can i avoid it?

Upvotes: 3

Views: 1334

Answers (1)

Paramasivan Samuttiram
Paramasivan Samuttiram

Reputation: 3738

Create category for UILabel and add the following code over there.

@implementation UILabel (CustomFontLabel)

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

@end

Upvotes: 11

Related Questions