NYBaseChartView.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // NYBaseChartView.h
  3. // NYChartDemo
  4. //
  5. // Created by kgj on 2023/3/17.
  6. //
  7. #import <UIKit/UIKit.h>
  8. //竖屏
  9. #define KISPortrait UIInterfaceOrientationIsPortrait(KAppInterfaceOrientation)
  10. //横屏
  11. #define KISLandscape UIInterfaceOrientationIsLandscape(KAppInterfaceOrientation)
  12. //屏幕宽度
  13. #define KDeviceWidth [UIScreen mainScreen].bounds.size.width
  14. //屏幕高度
  15. #define KDeviceHeight [UIScreen mainScreen].bounds.size.height
  16. //屏幕分辨率
  17. #define KScreen_Resolution (KDeviceWidth * KDeviceHeight * ([UIScreen mainScreen].scale))
  18. //主色调 and 文本常规色调等配置
  19. //随机色
  20. #define KRandomColor KRGBColor(arc4random_uniform(256)/255.0,arc4random_uniform(256)/255.0,arc4random_uniform(256)/255.0)
  21. // RGB颜色
  22. #define KRGBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
  23. // RGB颜色 alpha
  24. #define KRGBAColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
  25. //16进制颜色
  26. #define KRGB16Color(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]
  27. //Hex颜色 需要配置类扩展
  28. #define KHexColor(str) [UIColor colorWithHexString:(str)]
  29. //以iphone6为基础缩放系数
  30. #define Iphone6ScaleWidth KDeviceWidth/375.0
  31. //以iphone6为基础缩放系数
  32. #define Iphone6ScaleHeight KDeviceHeight/667.0
  33. //根据ip6的屏幕来拉伸宽
  34. #define KRealValue(x) ((x)*((KISPortrait ? KDeviceWidth : KDeviceHeight)/375.0f))
  35. //根据ip6的屏幕来拉伸宽Int
  36. #define KRealValueInt(x) ((NSInteger)((x)*((KISPortrait ? KDeviceWidth : KDeviceHeight)/375.0f)))
  37. //根据ip6的屏幕来拉伸高
  38. #define KRealHeightValue(height) ((height)*((KISPortrait ? KDeviceHeight : KDeviceWidth)/ 812.0f))
  39. //iphone5相对iphone6尺寸比例
  40. #define KIphoneSizeScale (KIs_Iphone_5?0.853:1.0)
  41. //屏幕方向
  42. #define KAppInterfaceOrientation \
  43. \
  44. ^(){ \
  45. UIInterfaceOrientation interfaceOrientation; \
  46. if (@available(iOS 13.0, *)) { \
  47. UIWindowScene *windowScene = (UIWindowScene *)[UIApplication sharedApplication].connectedScenes.allObjects.firstObject; \
  48. interfaceOrientation = windowScene.interfaceOrientation; \
  49. } else { \
  50. interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation; \
  51. } \
  52. return interfaceOrientation; \
  53. }()
  54. NS_ASSUME_NONNULL_BEGIN
  55. typedef void (^NYChartCellBlock)(id obj,int index);
  56. @protocol NYBaseChartViewDelegate <NSObject>
  57. @required
  58. - (void)loadView;
  59. @optional
  60. - (void)updateView;
  61. @end
  62. @interface NYBaseChartView : UIView
  63. /**
  64. * x轴数据
  65. */
  66. @property (nonatomic,strong,nullable) NSArray *arrayX;
  67. /**
  68. * y轴数据
  69. */
  70. @property (nonatomic,strong,nullable) NSArray *arrayY;
  71. /**
  72. * 点数据
  73. */
  74. @property (nonatomic,strong,nullable) NSMutableArray *pointArray;
  75. /**
  76. * 间隔时间
  77. */
  78. @property (nonatomic,assign) NSInteger interval_time;
  79. /**
  80. * x间隔 count 0 默认不间隔
  81. */
  82. @property (nonatomic,assign) NSInteger x_interval;
  83. /**
  84. * y间隔 count 0 默认不间隔
  85. */
  86. @property (nonatomic,assign) NSInteger y_interval;
  87. /**
  88. * x 字体色
  89. */
  90. @property (nonatomic,strong) UIColor *x_fontColor;
  91. /**
  92. * x 字体
  93. */
  94. @property (nonatomic,strong) UIFont *x_font;
  95. /**
  96. * y 字体色
  97. */
  98. @property (nonatomic,strong) UIColor *y_fontColor;
  99. /**
  100. * y 字体
  101. */
  102. @property (nonatomic,strong) UIFont *y_font;
  103. @end
  104. NS_ASSUME_NONNULL_END