2021-12-21 Category UIFont

2021-12-21  本文已影响0人  两米长的大白菜

系统字体category
.h

#import <UIKit/UIKit.h>

@interface UIFont (ALY)
/**
  PingFang-SC-Bold 字体,做了防空处理,粗体

 @param fontSize 字体大小
 @return 字体font
 */
+ (nullable UIFont *)alyBoldFontWithFontSize:(CGFloat)fontSize;

/**
 PingFang-SC-Regular 字体,做了防空处理,正常字体
 
 @param fontSize 字体大小
 @return 字体font
 */
+ (nullable UIFont *)alyRegularFontWithFontSize:(CGFloat)fontSize;
/**
 PingFang-SC-Light 字体,做了防空处理,正常字体
 
 @param fontSize 字体大小
 @return 字体font
 */
+ (UIFont *_Nullable)alyLightFontWithFontSize:(CGFloat)fontSize;

/**
 PingFangSC-Semibold 字体,做了防空处理,正常字体
 
 @param fontSize 字体大小
 @return 字体font
 */
+ (UIFont *_Nullable)alySemiboldFontWithFontSize:(CGFloat)fontSize;

/**
 PingFang-SC-Medium 字体,做了防空处理,正常字体
 
 @param fontSize 字体大小
 @return 字体font
 */
+ (UIFont *_Nullable)alyMediumFontWithFontSize:(CGFloat)fontSize;

/**
 Bebas设置字体展示

 @param fontSize 设置大小
 @return 返回字体
 */
+ (UIFont *_Nullable)alyBebasFontWithSize:(CGFloat)fontSize;

@end

.m

#import "UIFont+ALY.h"

@implementation UIFont (ALY)
+ (UIFont *)alyBoldFontWithFontSize:(CGFloat)fontSize{
    return [UIFont fontWithName:@"PingFang-SC-Bold" size:fontSize]?:[UIFont boldSystemFontOfSize:fontSize];
}
+ (UIFont *)alyRegularFontWithFontSize:(CGFloat)fontSize{
    return [UIFont fontWithName:@"PingFang-SC-Regular" size:fontSize]?:[UIFont systemFontOfSize:fontSize];
}

+ (UIFont *)alyLightFontWithFontSize:(CGFloat)fontSize{
    return [UIFont fontWithName:@"PingFang-SC-Light" size:fontSize]?:[UIFont systemFontOfSize:fontSize];
}
+ (UIFont *)alySemiboldFontWithFontSize:(CGFloat)fontSize{
    return [UIFont fontWithName:@"PingFangSC-Semibold" size:fontSize]?:[UIFont systemFontOfSize:fontSize];
}
+ (UIFont *)alyMediumFontWithFontSize:(CGFloat)fontSize {
    return [UIFont fontWithName:@"PingFangSC-Medium" size:fontSize]?:[UIFont systemFontOfSize:fontSize];
}
@end
上一篇 下一篇

猜你喜欢

热点阅读