123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #ifndef YMConstMacro_h
- #define YMConstMacro_h
- #import <CoreGraphics/CoreGraphics.h>
- #define YMPath_DOCUMENT [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
- #define kWindow \
- ({\
- UIWindow* window = nil;\
- if (@available(iOS 13.0, *)) { \
- for (UIWindowScene* windowScene in [UIApplication sharedApplication].connectedScenes){ \
- if (windowScene.activationState == UISceneActivationStateForegroundActive){ \
- window = windowScene.windows.firstObject; \
- break; \
- }\
- }\
- }\
- else { \
- window = [[UIApplication sharedApplication].delegate window];\
- }\
- window = [[UIApplication sharedApplication].delegate window];\
- (window);\
- })
- //查看程序运行位置
- #define CheckRunWhere NSLog(@"%s",__func__);
- //安全区域top
- #define kSafeAreaTop \
- ({\
- CGFloat top = 0.f;\
- if (@available(iOS 11,*)) {\
- top = [[[UIApplication sharedApplication] delegate] window].safeAreaInsets.top;\
- }\
- (top);\
- })
- //安全区域bottom
- #define kSafeAreaBottom \
- ({\
- CGFloat bottom = 0.f;\
- if (@available(iOS 11,*)) {\
- bottom = [[[UIApplication sharedApplication] delegate] window].safeAreaInsets.bottom;\
- }\
- (bottom);\
- })
- //是否iPhoneX
- #define ZYiPhoneX (kSafeAreaBottom > 0 ? YES : NO)
- //状态栏高度
- #define kStatusBarHeight (kSafeAreaTop > 0 ? kSafeAreaTop : 20)
- //navbar高度
- #define kNavBarHeight (44+kStatusBarHeight)
- //弱引用
- #define WS(weakSelf) __weak __typeof(&*self)weakSelf = self
- #ifndef kSCREEN_HEIGHT
- #define kSCREEN_HEIGHT (CGFloat)([[UIScreen mainScreen] bounds].size.height)
- #endif
- #ifndef kSCREEN_WIDTH
- #define kSCREEN_WIDTH (CGFloat)([[UIScreen mainScreen] bounds].size.width)
- #endif
- /** 参照宽高 375 * 812 **/
- #define KReferenceHeight 812.f
- #define KReferenceWidth 375.f
- /** 宽高比例 **/
- #define KScaleW (CGFloat)(kSCREEN_WIDTH/KReferenceWidth)
- #define KScaleH (CGFloat)(kSCREEN_HEIGHT/KReferenceHeight)
- #define YMUserDeafaults [NSUserDefaults standardUserDefaults]
- #define kMainScreenWidth [[UIScreen mainScreen] bounds].size.width
- #define kMainScreenHeight [[UIScreen mainScreen] bounds].size.height
- #define DEFAULT_CHANNEL_ID [YMUtil channelId]
- #define YMMainScreenScale [UIScreen mainScreen].scale
- #define ImageName(X) (UIImage*)([UIImage imageNamed:X])
- #define YMBoundRect(string,maxWidth,font) [string boundingRectWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:font} context:nil]
- #define YMBoundWidth(string,font) [string boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:font} context:nil]
- #define SLColor(X) (UIColor*)([UIColor colorFormString:X])
- //WeakSelf
- #define WEAKSELF typeof(self) __weak wkSelf = self;
- ///
- #define StrongWeakSelf typeof(wkSelf) __strong stSelf=wkSelf;
- #define SLBgColor SLColor(@"#F2F3F7")
- #define SLBlackColor SLColor(@"#273F66")
- #define SLBlueColor SLColor(@"#1677FF")
- #define SLBlueSelColor SLColor(@"#0052D9")
- #define SL333Color SLColor(@"#333333")
- #endif /* YMConstMacro_h */
|