-
-
Save binhho/aead6ee5802be72ed9c5 to your computer and use it in GitHub Desktop.
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
#import <UIKit/UIKit.h> | |
@interface UIButton (TCCustomFont) | |
@property (nonatomic, copy) NSString* fontName; | |
@end | |
@implementation UIButton (TCCustomFont) | |
- (NSString *)fontName { | |
return self.titleLabel.font.fontName; | |
} | |
- (void)setFontName:(NSString *)fontName { | |
self.titleLabel.font = [UIFont fontWithName:fontName size:self.titleLabel.font.pointSize]; | |
} | |
@end | |
@interface UILabel (TCCustomFont) | |
@property (nonatomic, copy) NSString* fontName; | |
@end | |
@implementation UILabel (TCCustomFont) | |
- (NSString *)fontName { | |
return self.font.fontName; | |
} | |
- (void)setFontName:(NSString *)fontName { | |
self.font = [UIFont fontWithName:fontName size:self.font.pointSize]; | |
} | |
@end | |
@interface UITextField (TCCustomFont) | |
@property (nonatomic, copy) NSString* fontName; | |
@end | |
@implementation UITextField (TCCustomFont) | |
- (NSString *)fontName { | |
return self.font.fontName; | |
} | |
- (void)setFontName:(NSString *)fontName { | |
self.font = [UIFont fontWithName:fontName size:self.font.pointSize]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment