NTESGlobalMacro.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // NTESGlobalMacro.h
  3. // NIMDemo
  4. //
  5. // Created by chris on 15/2/12.
  6. // Copyright (c) 2015年 Netease. All rights reserved.
  7. //
  8. #ifndef NIMDemo_GlobalMacro_h
  9. #define NIMDemo_GlobalMacro_h
  10. #define IOS11 ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 11.0)
  11. #define UIScreenWidth [UIScreen mainScreen].bounds.size.width
  12. #define UIScreenHeight [UIScreen mainScreen].bounds.size.height
  13. #define UISreenWidthScale UIScreenWidth / 320
  14. #define UICommonTableBkgColor UIColorFromRGB(0xe4e7ec)
  15. #define Message_Font_Size 14 // 普通聊天文字大小
  16. #define Notification_Font_Size 10 // 通知文字大小
  17. #define Chatroom_Message_Font_Size 16 // 聊天室聊天文字大小
  18. #define SuppressPerformSelectorLeakWarning(Stuff) \
  19. do { \
  20. _Pragma("clang diagnostic push") \
  21. _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
  22. Stuff; \
  23. _Pragma("clang diagnostic pop") \
  24. } while (0)
  25. #pragma mark - UIColor宏定义
  26. #define UIColorFromRGBA(rgbValue, alphaValue) [UIColor \
  27. colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
  28. green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \
  29. blue:((float)(rgbValue & 0x0000FF))/255.0 \
  30. alpha:alphaValue]
  31. #define UIColorFromRGB(rgbValue) UIColorFromRGBA(rgbValue, 1.0)
  32. #define dispatch_sync_main_safe(block)\
  33. if ([NSThread isMainThread]) {\
  34. block();\
  35. } else {\
  36. dispatch_sync(dispatch_get_main_queue(), block);\
  37. }
  38. #define dispatch_async_main_safe(block)\
  39. if ([NSThread isMainThread]) {\
  40. block();\
  41. } else {\
  42. dispatch_async(dispatch_get_main_queue(), block);\
  43. }
  44. /* weakSelf strongSelf reference */
  45. #define WEAK_SELF(weakSelf) __weak __typeof(&*self) weakSelf = self;
  46. #define STRONG_SELF(strongSelf) __strong __typeof(&*weakSelf) strongSelf = weakSelf;
  47. #endif