//
//  UIFont+FontSize.m
//  MobilePortal
//
//  Created by caiyang on 2020/6/9.
//  Copyright © 2020 yin chen. All rights reserved.
//

#import "UIFont+FontSize.h"

#import <objc/runtime.h>

#define kScale MIN([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) / 360

@implementation UIFont (FontSize)
//只执行一次的方法，在这个地方 替换方法
//+(void)load{
//
//    //保证线程安全
//    static dispatch_once_t onceToken;
//    dispatch_once(&onceToken, ^{
//        Class class = [self class];
//        //拿到系统方法
//        Method orignalMethod = class_getClassMethod(class, @selector(systemFontOfSize:));
//        //拿到自己定义的方法
//        Method myMethod = class_getClassMethod(class, @selector(test_systemFontOfSize:));
//        //交换方法
//        method_exchangeImplementations(orignalMethod, myMethod);
//    });
//}

//+ (UIFont *)test_systemFontOfSize:(CGFloat)fontSize{
//    UIFont *font = [UIFont test_systemFontOfSize:fontSize];
//    return font;
//}
+(UIFont *)test_systemFontOfSize:(CGFloat)fontSize{
    UIFont *font = [UIFont systemFontOfSize:kScale*fontSize];
    return font;
}
+(UIFont *)test_boldSystemFont:(CGFloat)fontSize{
    UIFont *font = [UIFont boldSystemFontOfSize:kScale*fontSize];
    return font;
}
+(UIFont *)test_fontWithName:(CGFloat)fontSize{
    UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:kScale*fontSize];
    return font;
}
@end
