Files
keyboard/keyBoard/KeyBoardPrefixHeader.pch
2025-10-29 19:13:35 +08:00

91 lines
2.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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 <UIKit/UIKit.h>
#import "KBHUD.h"
/// 项目
#import "BaseNavigationController.h"
#import "BaseTableView.h"
#import "BaseCell.h"
//-----------------------------------------------宏定义全局----------------------------------------------------------/
/// 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
// 当前 KeyWindowiOS 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)
#endif /* KeyBoardPrefixHeader_pch */