美文网首页
2021-12-21 Category UIFont

2021-12-21 Category UIFont

作者: 两米长的大白菜 | 来源:发表于2021-12-21 14:35 被阅读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

相关文章

网友评论

      本文标题:2021-12-21 Category UIFont

      本文链接:https://www.haomeiwen.com/subject/lsjxqrtx.html