This commit is contained in:
2025-11-06 14:02:22 +08:00
parent d7874829d9
commit 15fc9621cd
15 changed files with 337 additions and 16 deletions

View File

@@ -8,6 +8,11 @@
#ifndef KBConfig_h
#define KBConfig_h
// UIKit is needed for CGFloat and UIScreen used by size-adaptation helpers
#if __OBJC__
#import <UIKit/UIKit.h>
#endif
// 基础baseUrl
#ifndef KB_BASE_URL
#define KB_BASE_URL @"https://m1.apifoxmock.com/m1/5438099-5113192-default/"
@@ -45,6 +50,27 @@
#define KB_APP_SCHEME @"kbkeyboardAppExtension"
#endif
// --- 尺寸适配(以 375 设计稿为基准) ---
// 用法:传入设计稿上的数值,返回按当前屏幕宽度缩放后的值。
// 例如CGFloat padding = KBFit(16);
#ifndef KB_DESIGN_WIDTH
#define KB_DESIGN_WIDTH 375.0
#endif
#if __OBJC__
static inline CGFloat KBScreenWidth(void) {
return [UIScreen mainScreen].bounds.size.width;
}
static inline CGFloat KBScaleFactor(void) {
return KBScreenWidth() / (CGFloat)KB_DESIGN_WIDTH;
}
static inline CGFloat KBFit(CGFloat designValue) {
return designValue * KBScaleFactor();
}
#endif
// --- 常用宏 ---
// 弱引用 self在 block 中避免循环引用):使用处直接写 KBWeakSelf;
#ifndef KBWeakSelf