//
// UILabel+Font.m
#import "UILabel+Font.h"
@interface UILabel (Font)
@end
@implementation UILabel (Font)
+ (void)load{
staticdispatch_once_tonceToken;
dispatch_once(&onceToken, ^{
Method setTextMethod = class_getInstanceMethod([self class], NSSelectorFromString(@"setText:"));
MethodsetTextRunMethod =class_getInstanceMethod([selfclass],@selector(setTextRuntime:));
method_exchangeImplementations(setTextMethod, setTextRunMethod);
Method setTextMethod2 = class_getInstanceMethod([self class], NSSelectorFromString(@"setAttributedText:"));
MethodsetTextRunMethod2 =class_getInstanceMethod([selfclass],@selector(setAttributedTextFont:));
method_exchangeImplementations(setTextMethod2, setTextRunMethod2);
});
}
- (void)setTextRuntime:(NSString*)text{
[self setTextRuntime:text];
[self setFontNew];
}
- (void)setAttributedTextFont:(NSAttributedString*)attributedText{
[selfsetAttributedTextFont:attributedText];
if(attributedText.length>0) {
idmyObj = [[NSClassFromString(@"UIButtonLabel")alloc]init];
if(![selfisKindOfClass:[myObjclass]]) {
// NSLog(@"不是UIButtonLabel");
[selfsetFontNew];
}else{
NSLog(@"是UIButtonLabel");
}
}
}
- (void)setFontNew{
NSString*language = [DAConfiguserLanguage];
intlanguage1 =0;
if(!language) {
NSString*pfLanguageCode = [NSLocalepreferredLanguages][0];
if([pfLanguageCodehasPrefix:@"en"]) {
language1 =1;
}
}
if([languageisEqualToString:@"English"] || [languageisEqualToString:@"en"] || language1 ==1) {
[self setFont:[UIFont fontWithName:@"Arciform" size:self.font.pointSize]];
}
}
@end