ZCCommon.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //
  2. // ZCCommon.h
  3. // XLChat
  4. //
  5. // Created by 张灿 on 2017/10/24.
  6. // Copyright © 2017年 张灿. All rights reserved.
  7. //
  8. #ifndef ZCCommon_h
  9. #define ZCCommon_h
  10. #import "UIColor+YYAdd.h"
  11. #import "YOUPAILZMusicManager.h"
  12. #import "YOUPAILZChatRoomManager.h"
  13. #import "YOUPAILZIntimateManager.h"
  14. #import "ZCCategory.h"
  15. #import "ZCBaseVC.h"
  16. #import "ZCBaseWebVC.h"
  17. #import "ZCBaseNavigationVC.h"
  18. #import "ZCHUDHelper.h"
  19. #import "ZCRegularHelper.h"
  20. #import "ZCAlertSheetView.h"
  21. #import "ZCAlertSheetBtnView.h"
  22. #import "ZCShareSheetView.h"
  23. #import "ZCLiveTextView.h"
  24. #import "ZCNavMenuView.h"
  25. #import "ZCUtils.h"
  26. #import "SDWebImageManager.h"
  27. #import "UIImageView+WebCache.h"
  28. #import "UIButton+WebCache.h"
  29. // 屏幕尺寸
  30. #define kScreenBounds [UIScreen mainScreen].bounds
  31. #define kFrameWidth [UIScreen mainScreen].bounds.size.width
  32. #define kFrameHeight [UIScreen mainScreen].bounds.size.height
  33. ////屏幕系数
  34. //#define ScreenWidthCoefficientWith(pram) ((kFrameWidth - pram) / (375 - pram))
  35. //#define PopularScreenWidthCoefficientWith(pram) ((kFrameWidth - pram) / (360 - pram))
  36. #define ConstWidth 375.0f //屏幕系数常数 、UI图的标准尺寸
  37. #define ConstHeight 812.0f //屏幕系数常数 、UI图的标准尺寸
  38. #define KScreenEqualWidth(x) (x/ConstWidth*kFrameWidth)
  39. #define KScreenEqualHeight(y) (y/ConstHeight*kFrameHeight)
  40. //苹方-简 常规体
  41. //font-family: PingFangSC-Regular, sans-serif;
  42. #define QHFontPingFangRegular(font) [UIFont fontWithName:@"PingFangSC-Regular" size: font]
  43. //
  44. //苹方-简 极细体
  45. //font-family: PingFangSC-Ultralight, sans-serif;
  46. #define QHFontPingFangUltraligh(font) [UIFont fontWithName:@"PingFangSC-Ultralight" size: font]
  47. //苹方-简 细体
  48. //font-family: PingFangSC-Light, sans-serif;
  49. #define QHFontPingFangLight(font) [UIFont fontWithName:@"PingFangSC-Light" size: font]
  50. //苹方-简 纤细体
  51. //font-family: PingFangSC-Thin, sans-serif;
  52. #define QHFontPingFangThin(font) [UIFont fontWithName:@"PingFangSC-Thin" size: font]
  53. //苹方-简 中黑体
  54. //font-family: PingFangSC-Medium, sans-serif;
  55. #define QHFontPingFangMedium(font) [UIFont fontWithName:@"PingFangSC-Medium" size: font]
  56. //苹方-简 中粗体
  57. //font-family: PingFangSC-Semibold, sans-serif;
  58. #define QHFontPingFangSemibold(font) [UIFont fontWithName:@"PingFangSC-Semibold" size: font]
  59. //判断屏幕尺寸
  60. #define IS_IPHONE_4 ([[UIScreen mainScreen]bounds].size.height == 480.0)
  61. #define IS_IPHONE_5 ([[UIScreen mainScreen]bounds].size.height == 568.0)
  62. #define IS_IPHONE_6 ([[UIScreen mainScreen]bounds].size.height == 667.0)
  63. #define IS_IPHONE_6P ([[UIScreen mainScreen]bounds].size.height == 736.0)
  64. //系统版本大于等于
  65. #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
  66. #define IOS10 ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 10.0)
  67. #define IOS9 ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 9.0)
  68. //获取屏幕宽度
  69. #define KScreenWidth [UIScreen mainScreen].bounds.size.width
  70. #define ConstWidth 375.0f //屏幕系数常数 、UI图的标准尺寸
  71. #define ConstHeight 812.0f //屏幕系数常数 、UI图的标准尺寸
  72. #define WHScreenEqualWidth(x) (x/ConstWidth*kFrameWidth)
  73. #define WHScreenEqualHeight(y) (y/ConstHeight*kFrameHeight)
  74. //获取屏幕高度
  75. #define KScreenHeight [UIScreen mainScreen].bounds.size.height
  76. #define StatusBarHeight ([LCTools getStatusBarHight] == 0 ? (Is_iPhoneX ? 44 : 20) : [LCTools getStatusBarHight])//(Is_iPhoneX ? 44 : 20)
  77. #define NavBarHeight ([LCTools getStatusBarHight] + 44.0f)
  78. #define TabbarHeight (Is_iPhoneX ? (49.f+34.f) : 49.f)
  79. #define SafeHeight (Is_iPhoneX ? 34.f: 0)
  80. #define ScaleSize(value) ((KScreenWidth/375.0f) * value)
  81. #define ScaleHeight(value) ((KScreenHeight/667) * value)
  82. #define isIphoneX_XS (KScreenWidth == 375.f && KScreenHeight == 812.f ? YES : NO)
  83. #define isIphoneXR_XSMax (KScreenWidth == 414.f && KScreenHeight == 896.f ? YES : NO)
  84. #define Is_iPhoneX (isIphoneX_XS || isIphoneXR_XSMax)
  85. //#define Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
  86. //十六进制颜色表示
  87. #define kColors(str) ([UIColor colorWithHexString:str])
  88. #define HexColorFromRGB(rgbValue) [UIColor \
  89. colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
  90. green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
  91. blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  92. #define HexColorFromRGBA(rgbValue,a) [UIColor \
  93. colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
  94. green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
  95. blue:((float)(rgbValue & 0xFF))/255.0 alpha:a]
  96. //十进制颜色表示
  97. #define DecColorFromRGB(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
  98. #define DecColorFromRGBA(r, g, b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
  99. //文件路径
  100. #define DocumentPath ([NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject])
  101. //Caches目录路径
  102. #define CachesPath ([NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject])
  103. // 弱引用 强引用
  104. #define WeakSelf __weak __typeof(self)weakSelf = self
  105. #define StrongSelf __strong __typeof(weakSelf)strongSelf = weakSelf
  106. #endif /* ZCCommon_h */