NIMGlobalMacro.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // NIMGlobalMacro.h
  3. // NIMKit
  4. //
  5. // Created by chris.
  6. // Copyright (c) 2015年 Netease. All rights reserved.
  7. //
  8. #ifndef NIMKit_GlobalMacro_h
  9. #define NIMKit_GlobalMacro_h
  10. #define NIMKit_IOS11 ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 11.0)
  11. #define NIMKit_UIScreenWidth [UIScreen mainScreen].bounds.size.width
  12. #define NIMKit_UIScreenHeight [UIScreen mainScreen].bounds.size.height
  13. #define NIMKit_SuppressPerformSelectorLeakWarning(Stuff) \
  14. do { \
  15. _Pragma("clang diagnostic push") \
  16. _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
  17. Stuff; \
  18. _Pragma("clang diagnostic pop") \
  19. } while (0)
  20. #pragma mark - UIColor宏定义
  21. #define NIMKit_UIColorFromRGBA(rgbValue, alphaValue) [UIColor \
  22. colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
  23. green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \
  24. blue:((float)(rgbValue & 0x0000FF))/255.0 \
  25. alpha:alphaValue]
  26. #define NIMKit_UIColorFromRGB(rgbValue) NIMKit_UIColorFromRGBA(rgbValue, 1.0)
  27. #define NIMKit_Dispatch_Sync_Main(block)\
  28. if ([NSThread isMainThread]) {\
  29. block();\
  30. } else {\
  31. dispatch_sync(dispatch_get_main_queue(), block);\
  32. }
  33. #define NIMKit_Dispatch_Async_Main(block)\
  34. if ([NSThread isMainThread]) {\
  35. block();\
  36. } else {\
  37. dispatch_async(dispatch_get_main_queue(), block);\
  38. }
  39. /* weak reference */
  40. #define NIMKit_WEAK_SELF(weakSelf) __weak __typeof(&*self) weakSelf = self;
  41. #define NIMKit_STRONG_SELF(strongSelf) __strong __typeof(&*weakSelf) strongSelf = weakSelf;
  42. #endif