ConfigHeader.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950
  1. #import <Foundation/Foundation.h>
  2. #import <UIKit/UIKit.h>
  3. #import "UIImage+Extension.h"
  4. /*--------------------app的相关配置------------------*/
  5. /*------第三方SDK---App-Key------------------------相关值根据需要自行更改------------------------*/
  6. #define UmengAppKey @"5bd2b88bb465f583f80000f8"
  7. #define kAlipayAppKey @"2018110762008924"
  8. #define kWeChatAppKey @"wx05d1925fb9f0c50f"
  9. #define kWeChatAppSecret @"a6a116feaf464a3630352d5bd0124b55"
  10. #define AlipayAppKey @"2018110762008924"
  11. #define kQQAppKey @""
  12. #define SinaAppKey @""
  13. #define JPushAppKey @"b3c625895634920e706616d8"
  14. /*---------------------------------用户相关信息-------------------------------------*/
  15. #define kUsername @"usernameNew"
  16. #define kUserNickname @"userNicknameNew"
  17. #define kUserPassword @"userPassword"
  18. #define kUserID @"userID"
  19. #define kUserToken @"userToken"
  20. #define kUserPortraitUrl @"userPortraitUrl"
  21. #define kUserEmail @"userEmail"
  22. #define kUserGender @"userGender"
  23. #define kUserSign @"userSign"
  24. #define kUserTelephone @"userTelephone"
  25. #define kUserStatus @"userStatus"
  26. #define kUserType @"userType"
  27. #define kUserOSPlatform @"userOSPlatform"
  28. /*---------------------------------程序相关常数-------------------------------------*/
  29. //App Id、下载地址、评价地址
  30. #define kAppId @"593499239"
  31. #define kAppUrl [NSString stringWithFormat:@"https://itunes.apple.com/us/app/ling-hao-xian/id%@?ls=1&mt=8",kAppId]
  32. #define kRateUrl [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@",kAppId]
  33. #define kPlaceholderImage [UIImage imageNamed:@"placeholderImage.png"]
  34. /*---------------------------------程序全局通知---Notification-------------------------------------*/
  35. #define WechatOpenSDKNotification @"WechatOpenSDK"
  36. #define AlipaySDKNotification @"AlipaySDK"
  37. #define AfterUserLogined @"AfterUserLoginedSetRootViewControllerEqualToTabBarController"
  38. #define kWoodTableViewState @"kWoodTableViewState"
  39. //重新登录通知
  40. #define kReLoginNotification @"ReLoginNotification"
  41. #pragma mark - ——————— 用户相关 ————————
  42. //登录状态改变通知
  43. #define KNotificationLoginStateChange @"loginStateChange"
  44. //自动登录成功
  45. #define KNotificationAutoLoginSuccess @"KNotificationAutoLoginSuccess"
  46. //被踢下线
  47. #define KNotificationOnKick @"KNotificationOnKick"
  48. #define AppForceQuit PostNotification(KNotificationLoginStateChange, @NO)
  49. //用户信息缓存 名称
  50. #define KUserCacheName @"KUserCacheName"
  51. //用户model缓存
  52. #define KUserModelCache @"KUserModelCache"
  53. /**
  54. * 新增设备的通知
  55. */
  56. static NSString *classAcessAddNotification = @"ClassAcessAddNotification";
  57. #pragma mark 常用资源字符串
  58. static NSString *defaultAvatarString = @"mine_headimg";
  59. #pragma mark - ——————— 网络状态相关 ————————
  60. #define GetTagView(tag) [self.view viewWithTag:tag]
  61. #define GetSelfTagView(tag) [self viewWithTag:tag]
  62. //网络状态变化
  63. #define KNotificationNetWorkStateChange @"KNotificationNetWorkStateChange"
  64. #define GetTableViewCellFrom(tableView, cell) [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([cell class])]
  65. #define GetTableViewCell(cell) [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([cell class])]
  66. #define GetCollectionViewCell(cell) [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([cell class]) forIndexPath:indexPath]
  67. #define registerCell(cell) [self.tableView registerClass:[cell class] forCellReuseIdentifier:NSStringFromClass([cell class])]
  68. #define registerTableViewCell(cell, tableView) [tableView registerClass:[cell class] forCellReuseIdentifier:NSStringFromClass([cell class])]
  69. #define registerCollectionViewCell(cell) [self.collectionView registerClass:[cell class] forCellWithReuseIdentifier:NSStringFromClass([cell class])];
  70. #define registerCollectionViewCellFrom(collectionView, cell) [collectionView registerClass:[cell class] forCellWithReuseIdentifier:NSStringFromClass([cell class])];
  71. /*---------------------------------程序界面配置信息-------------------------------------*/
  72. //设置app界面字体及颜色
  73. #define kTitleFontLarge [UIFont boldSystemFontOfSize:25]//一级标题字号
  74. #define kTitleFontMiddle [UIFont boldSystemFontOfSize:19]//二级标题字号
  75. #define kTitleFontSmall [UIFont boldSystemFontOfSize:16]//三级标题字号
  76. #define kContentFontLarge [UIFont systemFontOfSize:19] //内容部分大字号
  77. #define kContentFontMiddle [UIFont systemFontOfSize:16] //内容部分中字号
  78. #define kContentFontSmall [UIFont systemFontOfSize:13] //内容部分小字号
  79. #define UIImageName(string) [UIImage imageNamed:string]
  80. /*--------------------------------颜色--------------------------------------*/
  81. ///App全局使用色
  82. #define AppThemeColor [UIColor xlsn0w_hexString:@"#57A1FF"]
  83. #define AppSubThemeColor [UIColor xlsn0w_hexString:@"#548EF0"]
  84. #define App_57A1FF_Color [UIColor xlsn0w_hexString:@"#57A1FF"]
  85. #define App_548EF0_Color [UIColor xlsn0w_hexString:@"#548EF0"]
  86. #define App_4E8AFF_Color [UIColor xlsn0w_hexString:@"#4E8AFF"]
  87. #define AppSecondLevelColor [UIColor xlsn0w_hexString:@"#C30E22"]
  88. #define AppViewBackgroundColor [UIColor xlsn0w_hexString:@"#F3F3F3"]
  89. #define AppBtnDisabledColor [UIColor xlsn0w_hexString:@"#D4D4D4"]
  90. #define AppBtnNormalColor AppThemeColor
  91. #define AppBtnHighlightedColor [UIColor xlsn0w_hexString:@"#289934"]
  92. #define AppPayBtnHighlightedColor [UIColor xlsn0w_hexString:@"#C57C3B"]
  93. #define AppBlackTextColorAlpha [UIColor xlsn0w_hexString:@"#000000" alpha:0.87]
  94. #define AppBlackTextColor [UIColor xlsn0w_hexString:@"#333333"]
  95. #define AppBlackSubTextColor [UIColor xlsn0w_hexString:@"#808080"]
  96. #define AppGrayTextColorAlpha [UIColor xlsn0w_hexString:@"#000000" alpha:0.54]
  97. #define AppGrayTextColor [UIColor xlsn0w_hexString:@"#757575"]
  98. #define AppRedTextColor [UIColor xlsn0w_hexString:@"#FF3C3C"]
  99. #define AppTitleColor [UIColor xlsn0w_hexString:@"#333333"]
  100. #define AppSubtitleColor [UIColor xlsn0w_hexString:@"#999999"]
  101. #define App333333TitleColor [UIColor xlsn0w_hexString:@"#333333"]
  102. #define App666666TitleColor [UIColor xlsn0w_hexString:@"#666666"]
  103. #define App999999TitleColor [UIColor xlsn0w_hexString:@"#999999"]
  104. #define AppCCCCCCTitleColor HexColor(@"#CCCCCC")
  105. #define AppPriceColor HexColor(@"#FC8D3C")
  106. #define AppBlackColor UIColor.blackColor
  107. #define AppWhiteColor UIColor.whiteColor
  108. #define App9AlphaWhiteColor [UIColor xlsn0w_hexString:@"#FFFFFF" alpha:0.9]
  109. #define App5AlphaWhiteColor [UIColor xlsn0w_hexString:@"#FFFFFF" alpha:0.5]
  110. #define AppLightGrayTextColor [UIColor xlsn0w_hexString:@"#000000" alpha:0.27]
  111. #define AppLineColor [UIColor xlsn0w_hexString:@"#000000" alpha:0.1]
  112. #define AppWhiteTextColorAlpha [UIColor xlsn0w_hexString:@"#FFFFFF" alpha:0.5]
  113. #define AppWhiteTextColor [UIColor xlsn0w_hexString:@"#FFFFFF"]
  114. #define ViewBgColor AppViewBackgroundColor
  115. #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
  116. #define AppCodeBtnHighlightedColor [UIColor xlsn0w_hexString:@"#0BB81D" alpha:0.2]
  117. #define AppTitleBtnHighlightedColor AppLineColor
  118. #define AppSystemFont(size) [UIFont systemFontOfSize:size]
  119. #define AppBoldSystemFont(size) [UIFont boldSystemFontOfSize:15]
  120. //导航栏颜色
  121. #define NavBgColor AppThemeColor
  122. #define NavBgFontColor HexFromRGB(0xFF6600)
  123. #define NavTitleColor [UIColor whiteColor]
  124. #define NavBgBtnTitleColor HexFromRGB(0x333333)
  125. #define TabBarTitleColor HexFromRGB(0xFF6600)
  126. #define whiteNavImage [UIImage imageNamed:@"whiteNav"]
  127. //提示view背景颜色
  128. #define PromptBgColor HexFromRGB(0xEF4545)
  129. //分割线颜色
  130. #define LineColor HexFromRGB(0xCCCCCC)
  131. //字体
  132. #define FontColor HexFromRGB(0x333333)
  133. //字体
  134. #define FontColor_secondary HexFromRGB(0x999999)
  135. //字体
  136. #define Font_otherColor HexFromRGB(0x81A1DF)
  137. //字体
  138. #define Font_otherColor1 HexFromRGB(0xFF6600)
  139. #define Font_otherColor2 HexFromRGB(0x666666)
  140. //次级字色
  141. #define FontColor1 HexFromRGB(0x1f1f1f)
  142. //再次级字色
  143. #define CFontColor2 HexFromRGB(0x5c5c5c)
  144. #define SYSTEMFONT(FONTSIZE) [UIFont systemFontOfSize:FONTSIZE]
  145. #pragma mark - 字体区
  146. /*---------------------------------字体-------------------------------------*/
  147. //主标题STHeitiSC-Medium
  148. #define FFontSC_Medium_17 [UIFont fontWithName:@"STHeitiSC-Medium" size:17.0f]
  149. #define FFontSC_Medium_16 [UIFont fontWithName:@"STHeitiSC-Medium" size:16.0f]
  150. #define FFontSC_Medium_15 [UIFont fontWithName:@"STHeitiSC-Medium" size:15.0f]
  151. #define FFontSC_Medium_14 [UIFont fontWithName:@"STHeitiSC-Medium" size:14.0f]
  152. #define FFontSC_Medium_13 [UIFont fontWithName:@"STHeitiSC-Medium" size:13.0f]
  153. #define FFontSC_Medium_12 [UIFont fontWithName:@"STHeitiSC-Medium" size:12.0f]
  154. #define FFontSC_Medium_11 [UIFont fontWithName:@"STHeitiSC-Medium" size:11.0f]
  155. #define FFontSC_Medium_10 [UIFont fontWithName:@"STHeitiSC-Medium" size:10.0f]
  156. #define FFontSC_Medium_09 [UIFont fontWithName:@"STHeitiSC-Medium" size:9.0f]
  157. #define FFont_25 [UIFont systemFontOfSize:25.0f]
  158. #define FFont_17 [UIFont systemFontOfSize:17.0f]
  159. #define FFont_16 [UIFont systemFontOfSize:16.0f]
  160. #define FFont_15 [UIFont systemFontOfSize:15.0f]
  161. #define FFont_14 [UIFont systemFontOfSize:14.0f]
  162. #define FFont_13 [UIFont systemFontOfSize:13.0f]
  163. #define FFont_12 [UIFont systemFontOfSize:12.0f]
  164. #define FFont_11 [UIFont systemFontOfSize:11.0f]
  165. #define FFont_10 [UIFont systemFontOfSize:10.0f]
  166. #define FFont_09 [UIFont systemFontOfSize:9.0f]
  167. //内容部分正常显示颜色和突出显示颜色
  168. #define kContentColorNormal [UIColor colorWithRed:57/255.0 green:32/255.0 blue:0/255.0 alpha:1]
  169. #define kContentColorHighlight [UIColor colorWithRed:0/255.0 green:191/255.0 blue:225/255.0 alpha:1]
  170. //几个常用色彩
  171. #define kGrayColor [UIColor colorWithRed:192/255.0 green:192/255.0 blue:192/255.0 alpha:1]
  172. #define kBlackColor [UIColor colorWithRed:50/255.0 green:50/255.0 blue:50/255.0 alpha:1]
  173. #define kRedColor [UIColor colorWithRed:255/255.0 green:110/255.0 blue:107/255.0 alpha:1]
  174. #define kBlueColor [UIColor colorWithRed:96/255.0 green:195/255.0 blue:202/255.0 alpha:1]
  175. #define kClearColor [UIColor clearColor]
  176. #define kWhiteColor [UIColor whiteColor]
  177. #define kAppBgColor [UIColor colorWithRed:236/255.0 green:236/255.0 blue:236/255.0 alpha:1]
  178. #define kMainColor [UIColor colorWithRed:64/255.0 green:168/255.0 blue:174/255.0 alpha:1]
  179. #define convertJSON(obj) [NSString convertJSONString:obj]
  180. //注意,关于 iOS10 系统版本的判断,可以用下面这个宏来判断。不能再用截取字符的方法。
  181. #define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
  182. #define currentApplication [UIApplication sharedApplication]
  183. #define UserSharedDefaults [NSUserDefaults standardUserDefaults]
  184. #define JPush_appKey @"83e03d123bf365100edb4d6b"
  185. #define JPush_registrationID @"JPush_registrationID"
  186. #define kNotification_HLHandleAgency @"kNotification_HLHandleAgency"
  187. //登录状态改变通知
  188. #define KNotificationLoginStateChange @"loginStateChange"
  189. #define HL_Application_Menu_Order [NSString stringWithFormat:@"%@%@", @"HL_Application_Menu_Order", [NSUSER_DEFAULT objectForKey:HL_User_Login_UserId]]
  190. #define HL_Application_menuJurisdiction [NSString stringWithFormat:@"%@%@", @"HL_Application_menuJurisdiction", [NSUSER_DEFAULT objectForKey:HL_User_Login_UserId]]
  191. #define HL_HLGuideView_timer [NSString stringWithFormat:@"%@%@", @"HL_HLGuideView_timer", [NSUSER_DEFAULT objectForKey:HL_User_Login_UserId]]
  192. //十六进制转换RGB
  193. #define HexFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  194. #define kAppWindow [UIApplication sharedApplication].delegate.window
  195. #define kKeyWindow [UIApplication sharedApplication].keyWindow
  196. #define heightRow 44
  197. #define nullType [NSNull class]
  198. #define responseNullData [data[@"data"] isKindOfClass:[NSNull class]]
  199. #define GetMethodName [MethodGetName printf_method_getName_currentClass:[self class]]
  200. #define width_scale ([UIScreen mainScreen].bounds.size.width / 375)///width*当前屏幕宽度比例
  201. #define height_scale ([UIScreen mainScreen].bounds.size.height / 667)///height*当前屏幕高度比例
  202. //是否是空对象
  203. #define isObjectNull(_object) (_object == nil \
  204. || [_object isKindOfClass:[NSNull class]] \
  205. || ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
  206. || ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))
  207. ///对象不为空
  208. #define isNotNull(obj) (!isObjectNull(obj))
  209. #define isNull(_object) (_object == nil \
  210. || [_object isKindOfClass:[NSNull class]] \
  211. || ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
  212. || ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))
  213. ///信息提示框
  214. #define show(text) [TipShow showCenterText:text];
  215. #define showBottom(text) [TipShow showBottomText:text];
  216. //系统版本
  217. #ifndef SystemVersion
  218. #define SystemVersion [UIDevice currentDevice].systemVersion.floatValue
  219. #endif
  220. #ifndef iOS6Later
  221. #define iOS6Later (SystemVersion >= 6)
  222. #endif
  223. #ifndef iOS7Later
  224. #define iOS7Later (SystemVersion >= 7)
  225. #endif
  226. #ifndef iOS8Later
  227. #define iOS8Later (SystemVersion >= 8)
  228. #endif
  229. #ifndef iOS9Later
  230. #define iOS9Later (SystemVersion >= 9)
  231. #endif
  232. #ifndef iOS9_1Later
  233. #define iOS9_1Later (SystemVersion >= 9.1f)
  234. #endif
  235. #ifndef iOS11Later
  236. #define iOS11Later (SystemVersion >= 11.0f)
  237. #endif
  238. #define AppDefaults [NSUserDefaults standardUserDefaults]
  239. #define AppShared [UIApplication sharedApplication]
  240. ///weak 弱引用对象
  241. #define WeakSelfObj(type) __weak typeof(type) weak##type = type;
  242. #define WeakObj(obj) autoreleasepool{} __weak typeof(obj) obj##Weak = obj;
  243. /* Xcode CodeSnippet添加如下代码块
  244. @WeakObj(<#obj#>);
  245. */
  246. /// iPhoneX = true
  247. #define is_iPhoneX_HL ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
  248. #define NavigationBar_Height_HL (is_iPhoneX_HL ? 88 : 64)
  249. #define Tabbar_Height_HL (is_iPhoneX_HL ? 83 : 49)
  250. #define SafeArea_Bottom_Height (is_iPhoneX_HL ? 34 : 0)
  251. #define StatusHeight_HL [[UIApplication sharedApplication] statusBarFrame].size.height
  252. #define kStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height
  253. #define kNavBarHeight 44.0
  254. //注意:请直接获取系统的tabbar高度,若没有用系统tabbar,建议判断屏幕高度;之前判断状态栏高度的方法不妥,如果正在通话状态栏会变高,导致判断异常,下面只是一个例子,请勿直接使用!
  255. #define kTopHeight (kStatusBarHeight + kNavBarHeight)
  256. #define iPhone4 ([[UIScreen mainScreen] bounds].size.height == 480)
  257. #define iPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)
  258. #define iPhone6 ([[UIScreen mainScreen] bounds].size.height == 667)
  259. #define iPhone6P ([[UIScreen mainScreen] bounds].size.height == 736)
  260. #define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
  261. #define NotificationDefaultCenter [NSNotificationCenter defaultCenter]
  262. /*---------------------------------判断设备相关---------------------------------------*/
  263. #define UI_IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  264. #define UI_IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  265. #define UI_IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
  266. #define SCREENSIZE_IS_35 (UI_IS_IPHONE && [[UIScreen mainScreen] bounds].size.height < 568.0)
  267. #define SCREENSIZE_IS_40 (UI_IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0)
  268. #define SCREENSIZE_IS_47 (UI_IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0)
  269. #define SCREENSIZE_IS_55 (UI_IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0 || [[UIScreen mainScreen] bounds].size.width == 736.0)
  270. //判断iPHoneXr
  271. #define SCREENSIZE_IS_XR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !UI_IS_IPAD : NO)
  272. //判断iPHoneX、iPHoneXs
  273. #define SCREENSIZE_IS_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !UI_IS_IPAD : NO)
  274. #define SCREENSIZE_IS_XS ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !UI_IS_IPAD : NO)
  275. //判断iPhoneXs Max
  276. #define SCREENSIZE_IS_XS_MAX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !UI_IS_IPAD : NO)
  277. #define IS_IPhoneX_All ([UIScreen mainScreen].bounds.size.height == 812 || [UIScreen mainScreen].bounds.size.height == 896)
  278. //状态栏、导航栏、标签栏高度
  279. #define Height_StatusBar [[UIApplication sharedApplication] statusBarFrame].size.height
  280. #define Height_NavBar 44.0f
  281. #define Height_TopBar (Height_StatusBar + Height_NavBar)
  282. #define Height_TapBar (IS_IPhoneX_All ? 83.0f:49.0f)
  283. #define Height_BottomSafe (IS_IPhoneX_All? 34.0f:0.0f)
  284. #define SCREEN_HEIGHTL [UIScreen mainScreen].bounds.size.height
  285. #define SCREEN_WIDTHL [UIScreen mainScreen].bounds.size.width
  286. #define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
  287. #define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
  288. #define RGB16(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  289. #define RGBAlpha(rgbValue,alphaValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:alphaValue]
  290. //判断iPhoneXs Max
  291. #define iPhoneXs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !UI_IS_IPAD : NO)
  292. //判断iPHoneXr
  293. #define iPhoneXr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !UI_IS_IPAD : NO)
  294. #define WoodType 0
  295. #define FruitType 1
  296. #define StoreType 2
  297. //判断是否是ipad
  298. #define isDevicePad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
  299. //判断iPhone4系列
  300. #define kiPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
  301. //判断iPhone5系列
  302. #define kiPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
  303. //判断iPhone6系列
  304. #define kiPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
  305. //判断iphone6+系列
  306. #define kiPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
  307. //判断iPhoneX
  308. #define IS_IPHONE_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
  309. //判断iPHoneXr
  310. #define IS_IPHONE_Xr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
  311. //判断iPhoneXs
  312. #define IS_IPHONE_Xs ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
  313. //判断iPhoneXs Max
  314. #define IS_IPHONE_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !isPad : NO)
  315. //iPhoneX系列
  316. #define iPhoneX_Height_StatusBar ((IS_IPHONE_X==YES || IS_IPHONE_Xr ==YES || IS_IPHONE_Xs== YES || IS_IPHONE_Xs_Max== YES) ? 44.0 : 20.0)
  317. #define iPhoneX_Height_NavBar ((IS_IPHONE_X==YES || IS_IPHONE_Xr ==YES || IS_IPHONE_Xs== YES || IS_IPHONE_Xs_Max== YES) ? 88.0 : 64.0)
  318. #define Height_TabBar ((IS_IPHONE_X==YES || IS_IPHONE_Xr ==YES || IS_IPHONE_Xs== YES || IS_IPHONE_Xs_Max== YES) ? 83.0 : 49.0)
  319. // 获取App的版本号
  320. #define AppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
  321. //获取系统对象
  322. #define kApplication [UIApplication sharedApplication]
  323. #define kAppWindow [UIApplication sharedApplication].delegate.window
  324. #define kAppDelegate (AppDelegate*)[UIApplication sharedApplication].delegate
  325. #define kRootViewController [UIApplication sharedApplication].delegate.window.rootViewController
  326. #define kUserDefaults [NSUserDefaults standardUserDefaults]
  327. #define kNotificationCenter [NSNotificationCenter defaultCenter]
  328. #define kStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height
  329. #define kNavHeight self.navigationController.navigationBar.frame.size.height
  330. #define kTabBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height>20?83:49)
  331. #define kTopHeight (kStatusBarHeight + kNavBarHeight)
  332. #define kNavStatusHeight self.navigationController.navigationBar.frame.size.height+[[UIApplication sharedApplication] statusBarFrame].size.height
  333. #define initUITableView [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-[self navHeight]-self.safeAreaBottomHeight) style:UITableViewStylePlain];
  334. #define initBaseTableView [[BaseTableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-[self navHeight]-self.safeAreaBottomHeight) style:UITableViewStylePlain];
  335. #define PriceFormat(price) [NSString convertPriceFormat:price]
  336. #define PriceFloatFormat(priceDouble) [NSString priceFormatFromDouble:priceDouble]
  337. /*
  338. iOS开发中,接受后台的响应,然后转化为模型对象,最终转化为NSString对象,然后控件显示出来。这一切都是那么的自然那么的熟悉。
  339. 一个数字,可以定义为number类型,也可以定义为字符串问题。如果后台返回的是字符串类型。在iOS json序列化的时候,会把字符串类型转化为NSString对象,这个一点问题没有。但是如果后台返回的是number类型。json序列化会将number类型转化为NSNumber对象。使用的时候,想当然的会将NSNumber转化为NSString对象。
  340. 让后台定义double类型数据66.6,你转化为字符串会发现就是66.59999999999999。
  341. 测试发现double转化为NSNumber的时候就会出现问题。double表示的字面值和其存储的值一般是不一样的,
  342. 转化为NSNumber之后,有很大一些数字,在NSNumber的stringValue上会出错。
  343. 解决方法可以是把取String的doubleValue,
  344. 然后再.2f保留两位小数进行构造字符串。
  345. 千万不能取floatValue,floatValue在大于15万的浮点数字就会出现不精确了(笔者做过遍历测试)。
  346. 而doubleValue在数十亿的范围内都是字面上精确的。
  347. 根本解决方法还是劝后台的同事把请求返回的数据全部设置为String类型
  348. 如果涉及到计算的问题,那就只得乖乖转化为NSDecimalNumber对象了。
  349. */
  350. //获取屏幕宽高
  351. #define kScreen_Bounds [UIScreen mainScreen].bounds
  352. #define Iphone6ScaleWidth KScreenWidth/375.0
  353. #define Iphone6ScaleHeight KScreenHeight/667.0
  354. //根据ip6的屏幕来拉伸
  355. #define kRealValue(with) ((with)*(KScreenWidth/375.0f))
  356. //强弱引用
  357. #define kWeakSelf(type) __weak typeof(type) weak##type = type;
  358. #define kStrongSelf(type) __strong typeof(type) type = weak##type;
  359. //View 圆角和加边框
  360. #define ViewBorderRadius(View, Radius, Width, Color)\
  361. \
  362. [View.layer setCornerRadius:(Radius)];\
  363. [View.layer setMasksToBounds:YES];\
  364. [View.layer setBorderWidth:(Width)];\
  365. [View.layer setBorderColor:[Color CGColor]]
  366. // View 圆角
  367. #define ViewRadius(View, Radius)\
  368. \
  369. [View.layer setCornerRadius:(Radius)];\
  370. [View.layer setMasksToBounds:YES]
  371. //property 属性快速声明 别用宏定义了,使用代码块+快捷键实现吧
  372. // 当前系统版本
  373. #define CurrentAppSystemVersion [[UIDevice currentDevice].systemVersion doubleValue]
  374. //当前语言
  375. #define CurrentAppLanguage [NSLocale preferredLanguages] objectAtIndex:0]
  376. //-------------------打印日志-------------------------
  377. //DEBUG 模式下打印日志,当前行
  378. #ifdef DEBUG
  379. #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
  380. #else
  381. #define DLog(...)
  382. #endif
  383. //拼接字符串
  384. #define NSStringFormat(format,...) [NSString stringWithFormat:format,##__VA_ARGS__]
  385. //颜色
  386. #define KClearColor [UIColor clearColor]
  387. #define KWhiteColor [UIColor whiteColor]
  388. #define KBlackColor [UIColor blackColor]
  389. #define KGrayColor [UIColor grayColor]
  390. #define KGray2Color [UIColor lightGrayColor]
  391. #define KBlueColor [UIColor blueColor]
  392. #define KRedColor [UIColor redColor]
  393. #define kRandomColor KRGBColor(arc4random_uniform(256)/255.0,arc4random_uniform(256)/255.0,arc4random_uniform(256)/255.0) //随机色生成
  394. //字体
  395. #define UIFont_boldSystemFontOfSize(FONTSIZE) [UIFont boldSystemFontOfSize:FONTSIZE]
  396. #define UIFont_systemFontOfSize(FONTSIZE) [UIFont systemFontOfSize:FONTSIZE]
  397. #define AppFont(NAME, FONTSIZE) [UIFont fontWithName:(NAME) size:(FONTSIZE)]
  398. //定义UIImage对象
  399. #define ImageWithFile(_pointer) [UIImage imageWithContentsOfFile:([[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@@%dx", _pointer, (int)[UIScreen mainScreen].nativeScale] ofType:@"png"])]
  400. #define IMAGE_NAMED(name) [UIImage imageNamed:name]
  401. //数据验证
  402. #define StrValid(f) (f!=nil && [f isKindOfClass:[NSString class]] && ![f isEqualToString:@""])
  403. #define SafeStr(f) (StrValid(f) ? f:@"")
  404. #define HasString(str,key) ([str rangeOfString:key].location!=NSNotFound)
  405. #define ValidStr(f) StrValid(f)
  406. #define ValidDict(f) (f!=nil && [f isKindOfClass:[NSDictionary class]])
  407. #define ValidArray(f) (f!=nil && [f isKindOfClass:[NSArray class]] && [f count]>0)
  408. #define ValidNum(f) (f!=nil && [f isKindOfClass:[NSNumber class]])
  409. #define ValidClass(f,cls) (f!=nil && [f isKindOfClass:[cls class]])
  410. #define ValidData(f) (f!=nil && [f isKindOfClass:[NSData class]])
  411. //获取一段时间间隔
  412. #define kStartTime CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
  413. #define kEndTime NSLog(@"Time: %f", CFAbsoluteTimeGetCurrent() - start)
  414. //打印当前方法名
  415. #define ITTDPRINTMETHODNAME() ITTDPRINT(@"%s", __PRETTY_FUNCTION__)
  416. //发送通知
  417. #define PostNotification(name, obj) [[NSNotificationCenter defaultCenter] postNotificationName:name object:obj];
  418. //#define AddObserver(sel, name) [[NSNotificationCenter defaultCenter] addObserver:self selector:sel name:name object:nil];
  419. //单例化一个类
  420. #define SINGLETON_FOR_HEADER(className) \
  421. \
  422. + (className *)shared##className;
  423. #define SINGLETON_FOR_CLASS(className) \
  424. \
  425. + (className *)shared##className { \
  426. static className *shared##className = nil; \
  427. static dispatch_once_t onceToken; \
  428. dispatch_once(&onceToken, ^{ \
  429. shared##className = [[self alloc] init]; \
  430. }); \
  431. return shared##className; \
  432. }
  433. //-------------------系统----------------
  434. #pragma mark - 系统
  435. //当前系统版本
  436. #define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
  437. //版本判断语句,是否是version以后的
  438. #define IOS(version) (([[[UIDevice currentDevice] systemVersion] intValue] >= version)?1:0)
  439. //获取当前语言
  440. #define GetCurrentAppLanguage [[NSLocale preferredLanguages] objectAtIndex:0]
  441. //检查系统版本
  442. #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
  443. #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
  444. #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
  445. #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
  446. #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
  447. //-------------------系统----------------
  448. //-------------------设备相关----------------
  449. #pragma mark - 设备相关
  450. //判断是什么大小的机型 4,4s ; 5,5s ; 6,6s ; 6+,6+s
  451. #define iphone4s CGSizeEqualToSize(CGSizeMake(640,960), [[UIScreen mainScreen]currentMode].size)
  452. #define iphone5 CGSizeEqualToSize(CGSizeMake(640,1136), [[UIScreen mainScreen]currentMode].size)
  453. #define iphone6 CGSizeEqualToSize(CGSizeMake(750,1334), [[UIScreen mainScreen]currentMode].size)
  454. #define iphone6Plus CGSizeEqualToSize(CGSizeMake(1242,2208), [[UIScreen mainScreen]currentMode].size)
  455. //获取屏幕宽度、高度
  456. #define appWidth [UIScreen mainScreen].bounds.size.width
  457. #define appHeight [UIScreen mainScreen].bounds.size.height
  458. //获取状态栏和导航栏高度
  459. #define appStatusBarHeight [UIApplication sharedApplication].statusBarFrame.size.height
  460. #define appNavigationBarHeight self.navigationController.navigationBar.frame.size.height
  461. //-------------------设备相关----------------
  462. #define ReplaceRootViewController(vc) [[AppDelegate shareAppDelegate] replaceRootViewController:vc]
  463. //-----------------警告处理----------------
  464. #define SuppressPerformSelectorLeakWarning(Stuff) \
  465. do { \
  466. _Pragma("clang diagnostic push") \
  467. _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
  468. Stuff; \
  469. _Pragma("clang diagnostic pop") \
  470. } while (0)
  471. //-----------------警告处理----------------
  472. /*--------------------------------开发中常用到的宏定义--------------------------------------*/
  473. //系统目录
  474. #define kDocuments [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]
  475. //----------方法简写-------
  476. #define mAppDelegate (AppDelegate *)[[UIApplication sharedApplication] delegate]
  477. #define mWindow [[[UIApplication sharedApplication] windows] lastObject]
  478. #define mKeyWindow [[UIApplication sharedApplication] keyWindow]
  479. #define mUserDefaults [NSUserDefaults standardUserDefaults]
  480. #define mNotificationCenter [NSNotificationCenter defaultCenter]
  481. //加载图片
  482. #define mImageByName(name) [UIImage imageNamed:name]
  483. #define mImageByPath(name, ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:name ofType:ext]]
  484. //以tag读取View
  485. #define mViewByTag(parentView, tag, Class) (Class *)[parentView viewWithTag:tag]
  486. //读取Xib文件的类
  487. #define mViewByNib(Class, owner) [[[NSBundle mainBundle] loadNibNamed:Class owner:owner options:nil] lastObject]
  488. //id对象与NSData之间转换
  489. #define mObjectToData(object) [NSKeyedArchiver archivedDataWithRootObject:object]
  490. #define mDataToObject(data) [NSKeyedUnarchiver unarchiveObjectWithData:data]
  491. //度弧度转换
  492. #define mDegreesToRadian(x) (M_PI * (x) / 180.0)
  493. #define mRadianToDegrees(radian) (radian*180.0) / (M_PI)
  494. //颜色转换
  495. #define mRGBColor(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0]
  496. #define mRGBAColor(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
  497. //rgb颜色转换(16进制->10进制)
  498. #define mRGBToColor(rgb) [UIColor colorWithRed:((float)((rgb & 0xFF0000) >> 16))/255.0 green:((float)((rgb & 0xFF00) >> 8))/255.0 blue:((float)(rgb & 0xFF))/255.0 alpha:1.0]
  499. //G-C-D
  500. #define kGCDBackground(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
  501. #define kGCDMain(block) dispatch_async(dispatch_get_main_queue(),block)
  502. //简单的以AlertView显示提示信息
  503. #define mAlertView(title, msg) \
  504. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:nil \
  505. cancelButtonTitle:@"确定" \
  506. otherButtonTitles:nil]; \
  507. [alert show];
  508. //----------页面设计相关-------
  509. #define mNavBarHeight 44
  510. #define mTabBarHeight 49
  511. #define mScreenWidth ([UIScreen mainScreen].bounds.size.width)
  512. #define mScreenHeight ([UIScreen mainScreen].bounds.size.height)
  513. //----------设备系统相关---------
  514. #define mRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
  515. #define mIsiP5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136),[[UIScreen mainScreen] currentMode].size) : NO)
  516. #define mIsPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  517. #define mIsiphone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  518. #define mIsiOS7 [[[UIDevice currentDevice] systemVersion] floatValue] == 7.0
  519. #define mIsiOS6 [[[UIDevice currentDevice] systemVersion] floatValue] == 6.0
  520. #define mSystemVersion ([[UIDevice currentDevice] systemVersion])
  521. #define mCurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
  522. #define mAPPVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
  523. #define mFirstLaunch mAPPVersion //以系统版本来判断是否是第一次启动,包括升级后启动。
  524. #define mFirstRun @"firstRun" //判断是否为第一次运行,升级后启动不算是第一次运行
  525. //--------调试相关-------
  526. //ARC
  527. #if __has_feature(objc_arc)
  528. //compiling with ARC
  529. #else
  530. #define mSafeRelease(object) [object release]; x=nil
  531. #endif
  532. //调试模式下输入NSLog,发布后不再输入。
  533. #ifndef __OPTIMIZE__
  534. #define NSLog(...) NSLog(__VA_ARGS__)
  535. #else
  536. #define NSLog(...) {}
  537. #endif
  538. #if mTargetOSiPhone
  539. //iPhone Device
  540. #endif
  541. #if mTargetOSiPhoneSimulator
  542. //iPhone Simulator
  543. #endif
  544. #define placeholderAppImage [UIImage imageNamed:@"PlaceholderImg"]
  545. #define defaultAvatarImage [UIImage imageNamed:@"defaultAvatar"]
  546. #define HomeCyclePlaceholderIMG [UIImage imageNamed:@"HomeCyclePlaceholderIMG"]
  547. /// CATransition Type
  548. static NSString * const TrAnimaType_Fade = @"fade"; //淡入淡出
  549. static NSString * const TrAnimaType_Push = @"push"; //推挤
  550. static NSString * const TrAnimaType_Reveal = @"reveal"; //揭开
  551. static NSString * const TrAnimaType_MoveIn = @"moveIn"; //覆盖
  552. static NSString * const TrAnimaType_Cube = @"cube"; //立方体
  553. static NSString * const TrAnimaType_SuckEffect = @"suckEffect"; //吮吸
  554. static NSString * const TrAnimaType_OglFlip = @"oglFlip"; //翻转
  555. static NSString * const TrAnimaType_RippleEffect = @"rippleEffect"; //波纹
  556. static NSString * const TrAnimaType_PageCurl = @"pageCurl"; //翻页
  557. static NSString * const TrAnimaType_PageUnCurl = @"pageUnCurl"; //反翻页
  558. static NSString * const TrAnimaType_CameraIrisHollowOpen = @"cameraIrisHollowOpen"; //开镜头
  559. static NSString * const TrAnimaType_CameraIrisHollowClose = @"cameraIrisHollowClose"; //关镜头
  560. static NSString * const TrAnimaType_CurlDown = @"curlDown"; //下翻页
  561. static NSString * const TrAnimaType_CurlUp = @"curlUp"; //上翻页
  562. static NSString * const TrAnimaType_FlipFromLeft = @"flipFromLeft"; //左翻转
  563. static NSString * const TrAnimaType_FlipFromRight = @"flipFromRight"; //右翻转
  564. #define IQKeyboardSharedManager [IQKeyboardManager sharedManager]
  565. //#define HexColor(hexString) [UIColor xlsn0w_hexString:hexString]
  566. #define GetPriceFromNumber(number) [NSString stringWithFormat:@"%.2f", [number floatValue]/100]
  567. #define GetOrderPriceFromNumber(number) [NSString stringWithFormat:@"%.2f", [number floatValue]]
  568. #define GetStringFromNumber(number) [XLsn0w xl_getNSStringWithNumber:number]
  569. #define GetNumberFromString(string) [XLsn0w xl_getNSNumberWithString:string];
  570. #define GetRMBPriceFromNumber(number) [NSString stringWithFormat:@"¥ %.2f", [number floatValue]/100]
  571. #define GetPriceUnitFromNumber(number) [NSString stringWithFormat:@"%.2f元", [number floatValue]/100]
  572. #define GetRMBPriceFromInt(int) [NSString stringWithFormat:@"¥ %.2f", int];
  573. #define GetPriceFromInt(int) [NSString stringWithFormat:@"%.2f", int];
  574. #define GetStringFromInt(int) [NSString stringWithFormat:@"%ld", int];
  575. ///搜索宏定义
  576. #define CJ_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
  577. //#define CJ_StatusBarHeight (CJ_iPhoneX ? 44.f : 20.f)
  578. //#define CJ_NavigationBarHeight 44.f
  579. //#define CJ_TabbarHeight (CJ_iPhoneX ? (49.f+34.f) : 49.f)
  580. //#define CJ_TabbarSafeBottomMargin (CJ_iPhoneX ? 34.f : 0.f)
  581. #define CJ_StatusBarAndNavigationBarHeight (CJ_iPhoneX ? 88.f : 64.f)
  582. //
  583. #define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
  584. #define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
  585. #define TableViewDefaultRect CGRectMake(0, 0, kScreenWidth, kScreenHeight)
  586. #define TableViewMinusNavHeightRect CGRectMake(0, 0, kScreenWidth, kScreenHeight-[self navHeight])
  587. //搜索框颜色
  588. #define kSearchBarTFDColor UIColorHex(0x00B38A)
  589. //文字颜色
  590. #define kMainTextColor UIColorHex(0x646464)
  591. #define UIColorHexString(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  592. /** 字体离边框的水平距离 */
  593. #define kTitleHorizontal_space 10.0f
  594. /** 字体离边框的竖直距离 */
  595. #define kTitleVertical_space 5.0f
  596. /** tagLab之间的水平间距 */
  597. #define kTagHorizontal_margin 15.0f
  598. /** tagLab之间的竖直间距 */
  599. #define kTagVertical_margin 10.0f
  600. /** tagLab与屏幕左右间距 */
  601. #define kTagScreen_margin 30
  602. /** tag字体 **/
  603. #define kTagFont [UIFont boldSystemFontOfSize:13]
  604. //标题高度
  605. static CGFloat const kTagTitleHeight = 20.f;
  606. //清除tip文本
  607. static NSString *const deleteTip = @"删除全部搜索历史?";
  608. //key
  609. static NSString *const kHistroySearchData = @"HistroySearchData";
  610. //最大历史搜索条数
  611. static NSInteger const kMaxHistroyNum = 10;
  612. #define iPhoneXRAndXSMAX (kScreenWidth == 414.f && kScreenHeight == 896.f ? YES : NO)
  613. // iPhoneX
  614. #define iPhoneXAndXS (kScreenWidth == 375.f && kScreenHeight == 812.f ? YES : NO)
  615. #define autoNavBarHeight ((iPhoneXAndXS || iPhoneXRAndXSMAX) ? 88.f : 64.f)
  616. #define ButtonHighlighted(button, backgroundColor) [button setBackgroundImage:[UIImage xlsn0w_imageWithColor:backgroundColor] forState:UIControlStateHighlighted];
  617. //比例适配
  618. #define WBaseWidth 375
  619. #define WBaseHeight 667
  620. #define logJSON(obj) XLsn0wLog(@"obj = %@", convertJSON(obj));
  621. #define logObj(obj) XLsn0wLog(@"obj = %@", obj);
  622. #define kScreenRect CGRectMake(0, 0, kScreenWidth, kScreenHeight)
  623. #define reloadTableViewData [self.tableView reloadData];///刷新UI
  624. #define reloadData(obj) [obj reloadData];
  625. #define IntegerFormat(integer) [NSString stringWithFormat:@"%ld", integer]
  626. #define IntFormat(int) [NSString stringWithFormat:@"%d", int]
  627. #define QwScaleW(valueSize) ((valueSize) * (kScreenWidth/WBaseWidth))
  628. #define QwScaleH(valueSize) ((valueSize) * (kScreenHeight/WBaseHeight))
  629. /***********************************************************************************************************************/
  630. /***********************************************************************************************************************/
  631. //融云 APPkey
  632. #define RCIMAppKey @"k51hidwqkn8kb"///测试
  633. //#define RCIMAppKey @"tdrvipkstq0t5"///正式
  634. #pragma mark 导航条的高度
  635. // 判断是否是iPhone X
  636. #define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
  637. //#define iPhoneX = (kScreenHeight == 812.0f) ? YES : NO;
  638. // 状态栏高度
  639. #define iPhoneXStatus_BAR_HEIGHT (iPhoneX ? 44.f : 20.f)
  640. // 导航栏高度
  641. #define iPhoneXNavgation_BAR_HEIGHT (iPhoneX ? 88.f : 64.f)
  642. // tabBar高度
  643. #define iPhoneXTab_BAR_HEIGHT (iPhoneX ? (49.f+34.f) : 49.f)
  644. // home indicator
  645. #define iPhoneXHOME_INDICATOR_HEIGHT (iPhoneX ? 34.f : 0.f)
  646. //屏幕比例
  647. #define WidthScale [UIScreen mainScreen].bounds.size.width/375.0
  648. #define HeightScale [UIScreen mainScreen].bounds.size.height/667.0
  649. //是否为空或是[NSNull null]
  650. #define IsNilOrNull(_ref) (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]))
  651. #define IsEmptyStr(_ref) (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) || ([(_ref)isEqualToString:@""]))
  652. #pragma mark 导航条的高度
  653. //导航条title的font
  654. #define kNavTitleFont UIFont_size(18.0)
  655. //标签栏item的font
  656. #define kTabBarItemFont UIFont_size(11.0)
  657. //选项卡的高度
  658. #define tabsHeight 45.0
  659. //预定义圆角数
  660. #define kAppMainCornerRadius 6.0
  661. #define jpush_channel @"App Store"
  662. #define jpush_key @"b3c625895634920e706616d8"
  663. #define MeiQiaKey @"c11c82f1864bb8b694b2062b47785460"//@"8a21df99c95dace806a41c02379efce6"
  664. #pragma mark 字体相关
  665. //字体
  666. #define UIFont_size(size) [UIFont systemFontOfSize:size]
  667. #define UIFont_bold_Size(size) [UIFont boldSystemFontOfSize:size]
  668. #pragma mark - Dev
  669. #define NotNilAndNullOutString(_ref) (((_ref) != nil) && (![(_ref) isEqual:[NSNull null]]))//字典 除String
  670. //是否为空或是[NSNull null]
  671. #define NotNilAndNull(_ref) (((_ref) != nil) && (![(_ref) isEqual:[NSNull null]]) && (![(_ref)isEqualToString:@""]))
  672. #define IsNilOrNull(_ref) (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]))
  673. #define IsEmptyStr(_ref) (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) || ([(_ref)isEqualToString:@""]))
  674. #define NotNull(_ref) (((_ref) != nil) && (![(_ref) isEqual:[NSNull null]]) ))
  675. #pragma mark 颜色相关
  676. //颜色
  677. #define UICOLOR_FROM_RGB(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
  678. #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  679. #define kAppBlackColor [UIColor blackColor] //黑色
  680. #define kAppGrayColor [UIColor grayColor] //灰色
  681. #define kAppDarkGrayColor [UIColor darkGrayColor] //深灰色
  682. #define kAppLightGrayColor [UIColor lightGrayColor] //浅灰色
  683. #define kAppWhiteColor [UIColor whiteColor] //白色
  684. #define kAppRedColor [UIColor redColor] //红色
  685. #define kAppOrangeColor [UIColor orangeColor] //橙色
  686. #define kAppClearColor [UIColor clearColor] //透明色
  687. #define kAppGreenColor [UIColor greenColor] //绿色
  688. #define KAppBackBgColor UICOLOR_FROM_RGB(240,240,240,1)//主背景色
  689. #define kAppBlueColor UICOLOR_FROM_RGB(29,121,164,1)
  690. #define kAppGoodColor UIColorFromRGB(0x1b82d1) //主调十六进制红色0x607d8b
  691. #define kAppHuiSeColor UIColorFromRGB(0xF5F5F5) //灰色啊
  692. #define kAppDarkTextColor [UIColor darkTextColor]
  693. #define kAppLightTextColor [UIColor lightTextColor]
  694. #define kAppLineColor UICOLOR_FROM_RGB(200,201,201,1)//细线的颜色
  695. #define kAppMainBgColor UICOLOR_FROM_RGB(236,237,239,1)
  696. //#define kCBlueBgColor UICOLOR_FROM_RGB(65,105,225,1)
  697. #define UICOLOR_FROM_RGB(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
  698. #define kViewBgColor UICOLOR_FROM_RGB(235,236,237,1)
  699. #define kFontColor UICOLOR_FROM_RGB(62,176,193,1)
  700. #define kFontBtnBgColor UICOLOR_FROM_RGB(254,219,10,1)
  701. #define kSectionFontColor UICOLOR_FROM_RGB(79,76,76,1)
  702. #define kOrderNumColor UICOLOR_FROM_RGB(62,176,193,1)
  703. #define kYellowBtnBgColor UICOLOR_FROM_RGB(255,222,0,1)
  704. #define kCyanBtnBgColor UICOLOR_FROM_RGB(62,176,193,1)
  705. #define SDColor(r, g, b, a) [UIColor colorWithRed:(r / 255.0) green:(g / 255.0) blue:(b / 255.0) alpha:a]
  706. #define Global_tintColor [UIColor colorWithRed:0 green:(190 / 255.0) blue:(12 / 255.0) alpha:1]
  707. #define Global_mainBackgroundColor SDColor(248, 248, 248, 1)
  708. #define TimeLineCellHighlightedColor [UIColor colorWithRed:92/255.0 green:140/255.0 blue:193/255.0 alpha:1.0]
  709. #define DAY @"day"
  710. #define NIGHT @"night"