UIFormatter.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. //
  2. // UIFormatter.h
  3. // test11
  4. //
  5. // Created by apple on 15/11/13.
  6. // Copyright (c) 2016年 JCZ. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. #import "UIImage+resize.h"
  11. #import "UIView+Frame.h"
  12. #pragma mark - UI宏
  13. #define kStatusHeight (kSize.height == 812.0 ? 44 : 20)
  14. #define kNavOffSet (kSize.height == 812.0 ? 88 : 64)
  15. #define kTabBarHeight (kSize.height == 812.0 ? 83 : 49)
  16. #define SafeAreaBottomHeight (kSize.height == 812.0 ? 34 : 0)
  17. #define kSegmentHeight 44
  18. #define kSize [[UIScreen mainScreen]bounds].size
  19. #ifndef kFrame
  20. #define kFrame [[UIScreen mainScreen]bounds]
  21. #endif
  22. //colors
  23. #define newBackGroundColor [UIColor colorWithRed:75/255.0 green:85/255.0 blue:132/255.0 alpha:1]
  24. #define newTitleColor [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1]
  25. #define newSubTitleColor [UIColor colorWithRed:200/255.0 green:200/255.0 blue:200/255.0 alpha:1]
  26. #define newContentTextColor [UIColor colorWithRed:150/255.0 green:150/255.0 blue:150/255.0 alpha:1]
  27. #define canClickColor [UIColor colorWithRed:134/255.0 green:204/255.0 blue:71/255.0 alpha:1]
  28. #define defGreen [UIColor colorWithRed:253/255.0 green:137/255.0 blue:38/255.0 alpha:1]
  29. #define backGroundColor [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1]
  30. #define stateBarColor [UIColor colorWithRed:22/255.0 green:90/255.0 blue:140/255.0 alpha:1]
  31. #define windowBlockColor [UIColor colorWithWhite:.2 alpha:.2]
  32. #define lineColor [UIColor colorWithWhite:.3 alpha:.1]
  33. #define titleColor [UIColor colorWithRed:70/255.0 green:70/255.0 blue:70/255.0 alpha:1]
  34. #define subTitleColor [UIColor colorWithWhite:.3 alpha:1]
  35. #define contentTextColor [UIColor colorWithRed:110/255.0 green:110/255.0 blue:110/255.0 alpha:1]
  36. #define RGBA_COLOR(R, G, B, A) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:A]
  37. #define RGB_COLOR(R, G, B) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:1.0f]
  38. //简单setFrame
  39. #define setxywh initWithFrame:CGRectMake(x, y, w, h)
  40. #define setDIYFrame CGRectMake(x, y, w, h)
  41. //字体
  42. #define largeFont [UIFont scaleSize:20 weight:10]
  43. #define midFont [UIFont scaleSize:14 weight:5]
  44. #define smallFont [UIFont scaleSize:10 weight:4]
  45. #define Font21 21
  46. #define Font18 18
  47. #define Font17 17
  48. #define Font16 16
  49. #define Font14 14
  50. #define Font10 10
  51. #define unOpenMsg @"暂未开放,敬请期待"
  52. /**自动屏幕适配,把屏幕当成320*480来写就行 该方法不适用于动画
  53. */
  54. CGRect SGRectMake(CGFloat x, CGFloat y,CGFloat width,CGFloat height);
  55. /**自动屏幕适配基础上,固定frame的height不进行适配
  56. */
  57. CGRect SGRectMakeCH(CGFloat x, CGFloat y,CGFloat width,CGFloat height);
  58. /**自动屏幕适配基础上,固定frame的y不进行适配
  59. */
  60. CGRect SGRectMakeCY(CGFloat x, CGFloat y,CGFloat width,CGFloat height);
  61. /**自动屏幕适配基础上,固定frame的y,heigh不进行适配
  62. */
  63. CGRect SGRectMakeCYH(CGFloat x, CGFloat y,CGFloat width,CGFloat height);
  64. CGSize SGSizeMake(CGFloat width,CGFloat height);
  65. /**自动屏幕适配的竖向float
  66. */
  67. CGFloat SGFloat(CGFloat k);
  68. @interface UIFormatter : NSObject
  69. @end
  70. //@interface UIViewController(Navigation)
  71. ///**通用导航栏,设置好leftBBI,及其事件
  72. // */
  73. //
  74. ///**通过导航栏返回上级菜单
  75. // */
  76. //-(void)configNavigationBar;
  77. //
  78. ////回到导航控制器的首页
  79. //-(void)configNavigationBarFirstVC;
  80. //
  81. //
  82. ///**隐藏导航栏
  83. // */
  84. //-(void)navPushHideTabbarToVC:(UIViewController*)vc;
  85. ///**这个是隐藏返回按钮的.主要是给搜教练VC用的。因为,它要禁止返回。
  86. // */
  87. //-(void)configNavigationBarHideLeft;
  88. ///**返回直接跳转到rootVC
  89. // */
  90. //-(void)configNavigationBarPopRoot;
  91. //
  92. //@end
  93. @interface UIView(formatter)
  94. -(void)setRound;
  95. -(void)setBoardWid:(CGFloat)width Color:(UIColor*)color;
  96. /**注意:这个headerView是添加到self的superview里面去的。
  97. */
  98. -(void)addViewWithRect:(CGRect)re Color:(UIColor*)color;
  99. -(void)addViewWithRect:(CGRect)re;
  100. /**这个是加到self。
  101. */
  102. -(void)addSelfViewWithRect:(CGRect)re Color:(UIColor*)color;
  103. -(void)scale:(CGFloat)rate;
  104. @end
  105. @interface UIImage (Extension)
  106. /**生成的图片的rect默认为100,100
  107. */
  108. + (UIImage *)imageWithColor:(UIColor *)color;
  109. @end
  110. @interface UIImage(tint)
  111. -(UIImage*)tint:(UIColor*)color;
  112. @end
  113. @interface UIImage (scale)
  114. -(UIImage*)originImageScaleToSize:(CGSize)size;
  115. @end
  116. @interface UIFont(scale)
  117. /**以6plus为基准。屏幕越小,字体越小
  118. */
  119. +(id)scaleSize:(CGFloat)font;
  120. @end
  121. @interface UILabel(formatter)
  122. -(void)setFont:(CGFloat)font TextColor:(UIColor*)color;
  123. -(void)setText:(NSString*)text Font:(CGFloat)font TextColor:(UIColor*)color;
  124. -(void)setText:(NSString*)text Font:(CGFloat)font TextColor:(UIColor*)color Alignment:(NSTextAlignment)align;
  125. @end
  126. UIImage* randomPortrait(void);
  127. UIColor * randomColor(void);
  128. void setRandomColor(UIView* vi);