133 lines
4.4 KiB
Plaintext
133 lines
4.4 KiB
Plaintext
//
|
||
// KeyBoardPrefixHeader.pch
|
||
// keyBoard
|
||
//
|
||
// Created by Mac on 2025/10/27.
|
||
//
|
||
|
||
#ifndef KeyBoardPrefixHeader_pch
|
||
#define KeyBoardPrefixHeader_pch
|
||
|
||
|
||
//Bugly
|
||
#define BuglyId @"5736ce7a19"
|
||
|
||
|
||
/// 三方
|
||
#import <Masonry/Masonry.h>
|
||
// 公共配置
|
||
#import "KBConfig.h"
|
||
|
||
/// 系统
|
||
#import <UIKit/UIKit.h>
|
||
#import "KBHUD.h"
|
||
#import "KBNetworkManager.h"
|
||
|
||
|
||
/// 项目
|
||
#import "UIViewController+Extension.h"
|
||
#import "BaseNavigationController.h"
|
||
#import "BaseTableView.h"
|
||
#import "BaseCell.h"
|
||
#import "KBLocalizationManager.h" // 全局多语言封装
|
||
|
||
|
||
//-----------------------------------------------宏定义全局----------------------------------------------------------/
|
||
// 通用链接(Universal Links)统一配置
|
||
// 仅需修改这里的域名/前缀,工程内所有使用 UL 的地方都会同步。
|
||
#define KB_UL_BASE @"https://app.tknb.net/ul" // 与 Associated Domains 一致
|
||
#define KB_UL_LOGIN KB_UL_BASE @"/login"
|
||
#define KB_UL_SETTINGS KB_UL_BASE @"/settings"
|
||
|
||
/// UI 尺寸/设备宏
|
||
// 屏幕尺寸
|
||
#define KB_SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
|
||
#define KB_SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
|
||
#define KB_ONE_PIXEL (1.0 / [UIScreen mainScreen].scale)
|
||
|
||
// 基础高度
|
||
#define KB_NAVBAR_BASE_HEIGHT 44.0
|
||
#define KB_TABBAR_BASE_HEIGHT 49.0
|
||
|
||
// 当前 KeyWindow(iOS 13 场景化兼容)
|
||
static inline UIWindow *KB_KeyWindow(void) {
|
||
UIWindow *window = nil;
|
||
if (@available(iOS 13.0, *)) {
|
||
for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) {
|
||
if (scene.activationState == UISceneActivationStateForegroundActive && [scene isKindOfClass:[UIWindowScene class]]) {
|
||
UIWindowScene *ws = (UIWindowScene *)scene;
|
||
for (UIWindow *w in ws.windows) {
|
||
if (w.isKeyWindow) { window = w; break; }
|
||
}
|
||
if (window) { break; }
|
||
}
|
||
}
|
||
if (!window) { window = UIApplication.sharedApplication.windows.firstObject; }
|
||
} else {
|
||
window = UIApplication.sharedApplication.keyWindow;
|
||
}
|
||
return window;
|
||
}
|
||
|
||
// Safe Area
|
||
static inline UIEdgeInsets KB_SafeAreaInsets(void) {
|
||
if (@available(iOS 11.0, *)) {
|
||
UIWindow *w = KB_KeyWindow();
|
||
return w ? w.safeAreaInsets : UIEdgeInsetsZero;
|
||
}
|
||
return UIEdgeInsetsZero;
|
||
}
|
||
|
||
static inline CGFloat KB_SafeAreaTop(void) { return KB_SafeAreaInsets().top; }
|
||
static inline CGFloat KB_SafeAreaBottom(void) { return KB_SafeAreaInsets().bottom; }
|
||
|
||
// 状态栏高度(iOS13+ 兼容)
|
||
static inline CGFloat KB_StatusBarHeight(void) {
|
||
if (@available(iOS 13.0, *)) {
|
||
UIWindow *w = KB_KeyWindow();
|
||
UIStatusBarManager *m = w.windowScene.statusBarManager;
|
||
return m ? m.statusBarFrame.size.height : 0.0;
|
||
} else {
|
||
return UIApplication.sharedApplication.statusBarFrame.size.height;
|
||
}
|
||
}
|
||
|
||
// 导航栏+状态栏总高度、TabBar 高度、是否异形屏
|
||
#define KB_STATUSBAR_HEIGHT (KB_StatusBarHeight())
|
||
#define KB_NAV_TOTAL_HEIGHT (KB_NAVBAR_BASE_HEIGHT + KB_StatusBarHeight())
|
||
#define KB_TABBAR_HEIGHT (KB_TABBAR_BASE_HEIGHT + KB_SafeAreaBottom())
|
||
#define KB_IS_IPHONEX_SERIES (KB_SafeAreaBottom() > 0.0)
|
||
|
||
|
||
|
||
|
||
// --- 设备特性:是否为带刘海机型(iPhone X 及以后异形屏)---
|
||
// 说明:在 iPhone 12 等机型底部会有 34px 安全区,这里通过安全区来判断是否为“刘海屏”。
|
||
// 注意:使用到 UIKit,这里自行引入,避免依赖 PCH 的包含顺序。
|
||
#import <UIKit/UIKit.h>
|
||
static inline BOOL KBDeviceHasNotchRuntime(void) {
|
||
if (@available(iOS 11.0, *)) {
|
||
UIWindow *window = nil;
|
||
if (@available(iOS 13.0, *)) {
|
||
for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) {
|
||
if (scene.activationState == UISceneActivationStateForegroundActive && [scene isKindOfClass:[UIWindowScene class]]) {
|
||
UIWindowScene *ws = (UIWindowScene *)scene;
|
||
for (UIWindow *w in ws.windows) { if (w.isKeyWindow) { window = w; break; } }
|
||
if (window) { break; }
|
||
}
|
||
}
|
||
if (!window) { window = UIApplication.sharedApplication.windows.firstObject; }
|
||
} else {
|
||
window = UIApplication.sharedApplication.keyWindow;
|
||
}
|
||
return window.safeAreaInsets.bottom > 0.0;
|
||
}
|
||
return NO;
|
||
}
|
||
|
||
#ifndef KB_DEVICE_HAS_NOTCH
|
||
#define KB_DEVICE_HAS_NOTCH (KBDeviceHasNotchRuntime())
|
||
#endif
|
||
|
||
#endif /* KeyBoardPrefixHeader_pch */
|