Skip to content

Instantly share code, notes, and snippets.

@rydermackay
Last active December 18, 2015 02:29
Show Gist options
  • Save rydermackay/5711390 to your computer and use it in GitHub Desktop.
Save rydermackay/5711390 to your computer and use it in GitHub Desktop.
How to customize UILabel’s font using UIAppearance.
//
// RGMAppDelegate.m
// UILabel+Appearance
//
// Created by Ryder Mackay on 2013-06-04.
// Copyright (c) 2013 Ryder Mackay. All rights reserved.
//
#import "RGMAppDelegate.h"
#import "UILabel+Appearance.h"
@implementation RGMAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILabel *label = [UILabel appearance];
label.rgm_font = [UIFont fontWithName:@"Avenir" size:17];
return YES;
}
@end
//
// UILabel+Appearance.h
// UILabel+Appearance
//
// Created by Ryder Mackay on 2013-06-04.
// Copyright (c) 2013 Ryder Mackay. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UILabel (Appearance)
@property (nonatomic, strong) UIFont *rgm_font UI_APPEARANCE_SELECTOR;
@end
//
// UILabel+Appearance.m
// UILabel+Appearance
//
// Created by Ryder Mackay on 2013-06-04.
// Copyright (c) 2013 Ryder Mackay. All rights reserved.
//
#import "UILabel+Appearance.h"
@implementation UILabel (Appearance)
- (UIFont *)rgm_font
{
return self.font;
}
- (void)setRgm_font:(UIFont *)rgm_font
{
self.font = rgm_font;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment