54 lines
1.1 KiB
Mathematica
54 lines
1.1 KiB
Mathematica
|
|
//
|
|||
|
|
// 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
|
|||
|
|
|