实现UIFont 的类别,通过runtime替换系统的方法
#import <objc/runtime.h>
@implementation UIFont (runtime)
+(void)load{
//获取替换后的类方法
Method newMethod = class_getClassMethod([self class], @selector(adjustFont:));
//获取替换前的类方法
Method method = class_getClassMethod([self class], @selector(systemFontOfSize:));
//然后交换类方法
method_exchangeImplementations(newMethod, method);
}
+(UIFont *)adjustFont:(CGFloat)fontSize{
UIFont *newFont=nil;
newFont = [UIFont adjustFont:fontSize * [UIScreen mainScreen].bounds.size.width/YourUIScreen];
return newFont;
}