VTMagicMacros.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // VTMagicMacros.h
  3. // VTMagicView
  4. //
  5. // Created by tianzhuo on 15/1/6.
  6. // Copyright (c) 2015年 tianzhuo. All rights reserved.
  7. //
  8. #ifndef VTMagicMacros_h
  9. #define VTMagicMacros_h
  10. /** 自定义Log,日志开关 0-关闭 1-开启 */
  11. #define __LOGDEBUG__ (0)
  12. #if defined(__LOGDEBUG__) && __LOGDEBUG__ && DEBUG
  13. #define VTLog(...) NSLog(__VA_ARGS__)
  14. #else
  15. #define VTLog(...)
  16. #endif
  17. // deprecated macro
  18. #define VT_DEPRECATED_IN(VERSION) __attribute__((deprecated("This property has been deprecated and will be removed in VTMagic " VERSION ".")))
  19. // weakSelf
  20. #define __DEFINE_WEAK_SELF__ __weak __typeof(&*self) weakSelf = self;
  21. #define __DEFINE_STRONG_SELF__ __strong __typeof(&*weakSelf) strongSelf = weakSelf;
  22. // 打印当前方法名
  23. #define VTPRINT_METHOD VTLog(@"==%@:%p running method '%@'==", self.class, self, NSStringFromSelector(_cmd));
  24. // 打印方法运行时间
  25. #define TIME_BEGIN NSDate * startTime = [NSDate date];
  26. #define TIME_END VTLog(@"time interval: %f", -[startTime timeIntervalSinceNow]);
  27. // 设置RGBA颜色值
  28. #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
  29. #define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(1.f)]
  30. // 十六进制转UIColor
  31. #define kVTColorFromHex(hexValue) [UIColor \
  32. colorWithRed:((float)((hexValue & 0xFF0000) >> 16))/255.0 \
  33. green:((float)((hexValue & 0xFF00) >> 8))/255.0 \
  34. blue:((float)(hexValue & 0xFF))/255.0 alpha:1.0]
  35. // 判断设备是否是iPhone
  36. #define kiPhoneDevice ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
  37. #define KiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
  38. // tabbar高度
  39. #define VTTABBAR_HEIGHT (49)
  40. // 状态栏高度
  41. #define VTSTATUSBAR_HEIGHT (KiPhoneX ? 44 : 20)
  42. #endif