Last active
December 18, 2015 02:29
-
-
Save rydermackay/5711390 to your computer and use it in GitHub Desktop.
How to customize UILabel’s font using UIAppearance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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