Files
peko-ios/YuMi/Global/YUMIMacroUitls.h
2024-12-18 17:12:48 +08:00

74 lines
2.7 KiB
Objective-C

//
// YMMacro.h
// YUMI
//
// Created by YUMI on 2021/9/10.
//
///一些宏
#import "NSBundle+Localizable.h"
#ifndef YUMIMacroUitls_h
#define YUMIMacroUitls_h
//iPhoneX系列设备(刘海屏设备)
#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 [[UIApplication sharedApplication] statusBarFrame].size.height
#define kStatusBarHeight statusbarHeight
#define kSafeAreaBottomHeight (iPhoneXSeries ? 34 : 0)
#define kSafeAreaTopHeight (iPhoneXSeries ? 24 : 0)
#define kNavigationHeight (kStatusBarHeight + 44)
#define kTabBarHeight (iPhoneXSeries ? 49.0+34.0 : 49.0)
#define kScreenScale ((CGFloat)KScreenWidth / (CGFloat)375)
#define kScreenHeightScale ((CGFloat)KScreenHeight / (CGFloat)812)
#define kHalfScreenHeight KScreenHeight * 0.65
#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;
///keyWindow
#define kWindow [UIApplication sharedApplication].keyWindow
#define kImage(image) [UIImage imageNamed:image]
///UIFont
#define kFontLight(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightLight]
#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 kFontHeavy(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightHeavy]
///内置版本号
#define PI_App_Version @"1.0.33"
///渠道
#define PI_App_Source @"appstore"
#define PI_Test_Flight @"TestFlight"
#define ISTestFlight 0
///正式环境
#define API_HOST_URL @"https://api.hfighting.com"
///测试环境
#define API_HOST_TEST_URL @"http://beta.api.molistar.xyz"
#define API_Image_URL @"https://image.hfighting.com"
#define YMLocalizedString(key) \
[NSBundle ymLocalizedStringForKey:(key)]
#define isMSRTL() [[NSBundle getLanguageText] hasPrefix:@"ar"]
///是否是中文
#define isMSZH() [[NSBundle getLanguageText] hasPrefix:@"zh"]
///是否是英文
#define isMSEN() [[NSBundle getLanguageText] hasPrefix:@"en"]
///是否土耳其语
#define isMSTR() [[NSBundle getLanguageText] hasPrefix:@"tr"]
#endif /* YUMIMacroUitls_h */