封装KBFont,适配字体

This commit is contained in:
2025-11-25 15:36:16 +08:00
parent 71423df1c0
commit 1eb73f5257
40 changed files with 224 additions and 101 deletions

53
Shared/KBFont.m Normal file
View File

@@ -0,0 +1,53 @@
//
// KBFont.m
//
#import "KBFont.h"
#if __OBJC__
@implementation KBFont
+ (UIFont *)fontOfSize:(CGFloat)designSize weight:(UIFontWeight)weight {
// 375 稿 KBConfig.h KBFit
CGFloat scaledSize = KBFit(designSize);
return [UIFont systemFontOfSize:scaledSize weight:weight];
}
+ (UIFont *)regular:(CGFloat)designSize {
return [self fontOfSize:designSize weight:UIFontWeightRegular];
}
+ (UIFont *)medium:(CGFloat)designSize {
return [self fontOfSize:designSize weight:UIFontWeightMedium];
}
+ (UIFont *)semibold:(CGFloat)designSize {
return [self fontOfSize:designSize weight:UIFontWeightSemibold];
}
+ (UIFont *)bold:(CGFloat)designSize {
return [self fontOfSize:designSize weight:UIFontWeightBold];
}
#pragma mark -
+ (UIFont *)titleFont {
// 18pt
return [self fontOfSize:18.0 weight:UIFontWeightSemibold];
}
+ (UIFont *)bodyFont {
// 14pt
return [self regular:14.0];
}
+ (UIFont *)captionFont {
// 12pt
return [self regular:12.0];
}
@end
#endif