Skip to content

Instantly share code, notes, and snippets.

@advantis
Created May 30, 2012 12:00
Show Gist options
  • Save advantis/2835817 to your computer and use it in GitHub Desktop.
Save advantis/2835817 to your computer and use it in GitHub Desktop.
UILabel category for setting custom font in IB
//
// Copyright © 2012 Yuri Kotov
//
#import <UIKit/UIKit.h>
@interface UILabel (NibFont)
@property (nonatomic, copy) NSString *fontName;
@property (nonatomic) CGFloat fontSize;
@end
//
// Copyright © 2012 Yuri Kotov
//
#import "UILabel+NibFont.h"
@implementation UILabel (NibFont)
- (NSString *) fontName
{
return self.font.fontName;
}
- (void) setFontName:(NSString *)name
{
self.font = [UIFont fontWithName:name size:self.fontSize];
}
- (CGFloat) fontSize
{
return self.font.pointSize;
}
- (void) setFontSize:(CGFloat)size
{
self.font = [UIFont fontWithName:self.fontName size:size];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment