Files
real-e-party-iOS/YuMi/Global/YUMIMacroUitls.h
2025-10-17 14:52:29 +08:00

84 lines
2.7 KiB
Objective-C

// Created by YUMI on 2021/9/10.
#import <Foundation/Foundation.h>
#import "../Tools/Bundle/NSBundle+Localizable.h"
#ifndef YUMIMacroUitls_h
#define YUMIMacroUitls_h
#import "../Tools/Bundle/YMLanguageConfig.h"
#define iPhoneXSeries \
({BOOL isPhoneXSeries = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneXSeries = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneXSeries);})
#define KScreenWidth [[UIScreen mainScreen] bounds].size.width
#define KScreenHeight [[UIScreen mainScreen] bounds].size.height
#define statusbarHeight ({\
CGFloat height = 0;\
if (@available(iOS 13.0, *)) {\
UIWindowScene *windowScene = (UIWindowScene *)[[[UIApplication sharedApplication] connectedScenes] allObjects].firstObject;\
height = windowScene.statusBarManager.statusBarFrame.size.height;\
} else {\
height = [[UIApplication sharedApplication] statusBarFrame].size.height;\
}\
height;\
})
#define kStatusBarHeight statusbarHeight
#define kSafeAreaBottomHeight (iPhoneXSeries ? 34 : 0)
#define kSafeAreaTopHeight (iPhoneXSeries ? 24 : 0)
#define kNavigationHeight (kStatusBarHeight + 44)
#define kScreenScale ((CGFloat)KScreenWidth / (CGFloat)375)
#define kGetScaleWidth(width) kRoundValue(width)
#define kRoundValue(value) round(kScreenScale * value)
#define kWeakify(o) try{}@finally{} __weak typeof(o) o##Weak = o;
#define kStrongify(o) autoreleasepool{} __strong typeof(o) o = o##Weak;
#define kWindow ({\
UIWindow *window = nil;\
if (@available(iOS 13.0, *)) {\
for (UIWindowScene *scene in [UIApplication sharedApplication].connectedScenes) {\
if (scene.activationState == UISceneActivationStateForegroundActive) {\
for (UIWindow *w in scene.windows) {\
if (w.isKeyWindow) {\
window = w;\
break;\
}\
}\
if (window) break;\
}\
}\
} else {\
window = [UIApplication sharedApplication].keyWindow;\
}\
window;\
})
#define kImage(image) [UIImage imageNamed:image]
#define kFontRegular(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightRegular]
#define kFontMedium(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightMedium]
#define kFontSemibold(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightSemibold]
#define kFontBold(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightBold]
#define PI_App_Version @"1.0.0"
#define API_HOST_URL @"https://api.epartylive.com"
#define YMLocalizedString(key) \
[NSBundle ymLocalizedStringForKey:(key)]
#endif