UINavigationBar+Extesion.m 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. //
  2. // UINavigationBar+Extesion.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/4/21.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "UINavigationBar+Extesion.h"
  9. @implementation UINavigationBar (Extesion)
  10. - (void)setClearBar{
  11. self.translucent = YES;
  12. [self setBackgroundImage:[UIImage imageWithColor:HexColorFromRGBA(0xffffff, 0) size:CGSizeMake(KScreenWidth, NavBarHeight)] forBarMetrics:(UIBarMetricsDefault)];
  13. if (@available(iOS 15.0, *)) {
  14. [self.scrollEdgeAppearance setBackgroundImage:[UIImage imageWithColor:HexColorFromRGBA(0xffffff, 0) size:CGSizeMake(KScreenWidth, NavBarHeight)]];
  15. [self.standardAppearance setBackgroundImage:[UIImage imageWithColor:HexColorFromRGBA(0xffffff, 0) size:CGSizeMake(KScreenWidth, NavBarHeight)]];
  16. }
  17. NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  18. textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
  19. textAttrs[NSFontAttributeName] = LCBFont17;
  20. [self setTitleTextAttributes:textAttrs];
  21. }
  22. - (void)setPupleGradientBar{
  23. UIImage *img = [LCTools ColorImage:CGSizeMake(KScreenWidth, NavBarHeight) FromColors:@[HexColorFromRGB(0xd975ff),HexColorFromRGB(0x744df8)] ByGradientType:(GradientLeftToRight)];
  24. [self setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
  25. if (@available(iOS 15.0, *)) {
  26. [self.scrollEdgeAppearance setBackgroundImage:img];
  27. [self.standardAppearance setBackgroundImage:img];
  28. }
  29. NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  30. textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
  31. textAttrs[NSFontAttributeName] = LCBFont17;
  32. [self setTitleTextAttributes:textAttrs];
  33. }
  34. - (void)setBlueGradientBar{
  35. UIImage *img = [LCTools ColorImage:CGSizeMake(KScreenWidth, NavBarHeight) FromColors:@[LCGradientOneColor,LCGradientTwoColor] ByGradientType:GradientLeftToRight];
  36. [self setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
  37. if (@available(iOS 15.0, *)) {
  38. [self.scrollEdgeAppearance setBackgroundImage:img];
  39. [self.standardAppearance setBackgroundImage:img];
  40. }
  41. NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  42. textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
  43. textAttrs[NSFontAttributeName] = LCBFont17;
  44. [self setTitleTextAttributes:textAttrs];
  45. }
  46. - (void)setPinkGradientBar
  47. {
  48. UIImage *img = [LCTools ColorImage:CGSizeMake(KScreenWidth, NavBarHeight) FromColors:@[ZYShadeOneColor,ZYShadeTwoColor] ByGradientType:GradientLeftToRight];
  49. [self setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
  50. if (@available(iOS 15.0, *)) {
  51. [self.scrollEdgeAppearance setBackgroundImage:img];
  52. [self.standardAppearance setBackgroundImage:img];
  53. }
  54. NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  55. textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
  56. textAttrs[NSFontAttributeName] = LCBFont17;
  57. [self setTitleTextAttributes:textAttrs];
  58. }
  59. - (void)setPureColorGradientBar{
  60. UIImage *img = [LCTools ColorImage:CGSizeMake(KScreenWidth, NavBarHeight) FromColors:@[HexColorFromRGB(0xF66DDF),HexColorFromRGB(0xF66DDF)] ByGradientType:GradientLeftToRight];
  61. [self setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
  62. if (@available(iOS 15.0, *)) {
  63. [self.scrollEdgeAppearance setBackgroundImage:img];
  64. [self.standardAppearance setBackgroundImage:img];
  65. }
  66. NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  67. textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
  68. textAttrs[NSFontAttributeName] = LCBFont17;
  69. [self setTitleTextAttributes:textAttrs];
  70. }
  71. - (void)setDefaultBar{
  72. self.translucent = NO;
  73. UIImage *img = [UIImage imageWithColor:[UIColor whiteColor] size:CGSizeMake(KScreenWidth, NavBarHeight)];
  74. NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  75. textAttrs[NSForegroundColorAttributeName] = LZ273145Color;
  76. textAttrs[NSFontAttributeName] = LCBFont17;
  77. if (@available(iOS 15.0, *)) {
  78. self.scrollEdgeAppearance.titleTextAttributes = textAttrs;
  79. self.standardAppearance.titleTextAttributes = textAttrs;
  80. [self.scrollEdgeAppearance setBackgroundImage:img];
  81. [self.standardAppearance setBackgroundImage:img];
  82. }
  83. [self setBackgroundImage:img forBarMetrics:(UIBarMetricsDefault)];
  84. [self setTitleTextAttributes:textAttrs];
  85. }
  86. - (void)setBrownBar
  87. {
  88. self.translucent = NO;
  89. UIImage *img = [UIImage imageWithColor:HexColorFromRGB(0xB7958C) size:CGSizeMake(KScreenWidth, NavBarHeight)];
  90. [self setBackgroundImage:img forBarMetrics:(UIBarMetricsDefault)];
  91. if (@available(iOS 15.0, *)) {
  92. [self.scrollEdgeAppearance setBackgroundImage:img];
  93. [self.standardAppearance setBackgroundImage:img];
  94. }
  95. // NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  96. // textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
  97. // textAttrs[NSFontAttributeName] = LCBFont17;
  98. // [self setTitleTextAttributes:textAttrs];
  99. }
  100. - (void)setBlackBar
  101. {
  102. self.translucent = NO;
  103. UIImage *img = [UIImage imageWithColor:HexColorFromRGB(0x1C1D23) size:CGSizeMake(KScreenWidth, NavBarHeight)];
  104. NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  105. textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
  106. textAttrs[NSFontAttributeName] = LCBFont17;
  107. if (@available(iOS 15.0, *)) {
  108. self.scrollEdgeAppearance.titleTextAttributes = textAttrs;
  109. self.standardAppearance.titleTextAttributes = textAttrs;
  110. [self.scrollEdgeAppearance setBackgroundImage:img];
  111. [self.standardAppearance setBackgroundImage:img];
  112. }
  113. [self setBackgroundImage:img forBarMetrics:(UIBarMetricsDefault)];
  114. [self setTitleTextAttributes:textAttrs];
  115. }
  116. - (void)setBlackBar1
  117. {
  118. self.translucent = NO;
  119. UIImage *img = [UIImage imageWithColor:HexColorFromRGB(0x000000) size:CGSizeMake(KScreenWidth, NavBarHeight)];
  120. [self setBackgroundImage:img forBarMetrics:(UIBarMetricsDefault)];
  121. if (@available(iOS 15.0, *)) {
  122. [self.scrollEdgeAppearance setBackgroundImage:img];
  123. [self.standardAppearance setBackgroundImage:img];
  124. }
  125. // NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  126. // textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
  127. // textAttrs[NSFontAttributeName] = LCBFont17;
  128. // [self setTitleTextAttributes:textAttrs];
  129. }
  130. -(void)setGoldGradientBar
  131. {
  132. self.translucent = NO;
  133. UIImage *img = [LCTools ColorImage:CGSizeMake(KScreenWidth, NavBarHeight) FromColors:@[HexColorFromRGB(0xFFD984),HexColorFromRGB(0xC4974B)] ByGradientType:(GradientTopToBottom)];
  134. [self setBackgroundImage:img forBarMetrics:(UIBarMetricsDefault)];
  135. if (@available(iOS 15.0, *)) {
  136. [self.scrollEdgeAppearance setBackgroundImage:img];
  137. [self.standardAppearance setBackgroundImage:img];
  138. }
  139. }
  140. -(void)setGrayGradientBar
  141. {
  142. self.translucent = NO;
  143. UIImage *img = [LCTools ColorImage:CGSizeMake(KScreenWidth, NavBarHeight) FromColors:@[HexColorFromRGB(0x7A767E),HexColorFromRGB(0x6F6C73)] ByGradientType:(GradientTopToBottom)];
  144. [self setBackgroundImage:img forBarMetrics:(UIBarMetricsDefault)];
  145. if (@available(iOS 15.0, *)) {
  146. [self.scrollEdgeAppearance setBackgroundImage:img];
  147. [self.standardAppearance setBackgroundImage:img];
  148. }
  149. }
  150. - (void)setFaintYellowBar
  151. {
  152. self.translucent = NO;
  153. UIImage *img = [UIImage imageWithColor:HexColorFromRGB(0xFCF8F1) size:CGSizeMake(KScreenWidth, NavBarHeight)];
  154. [self setBackgroundImage:img forBarMetrics:(UIBarMetricsDefault)];
  155. if (@available(iOS 15.0, *)) {
  156. [self.scrollEdgeAppearance setBackgroundImage:img];
  157. [self.standardAppearance setBackgroundImage:img];
  158. }
  159. }
  160. - (void)setFaintGrayBar
  161. {
  162. self.translucent = NO;
  163. [self setBackgroundImage:[UIImage imageWithColor:HexColorFromRGB(0xF6F6F6) size:CGSizeMake(KScreenWidth, NavBarHeight)] forBarMetrics:(UIBarMetricsDefault)];
  164. }
  165. - (void)setFaintOrangeBar
  166. {
  167. self.translucent = NO;
  168. [self setBackgroundImage:[UIImage imageWithColor:HexColorFromRGB(0xFFF6F4) size:CGSizeMake(KScreenWidth, NavBarHeight)] forBarMetrics:(UIBarMetricsDefault)];
  169. }
  170. ///// 子爵
  171. //- (void)setViscountBar{
  172. // self.translucent = NO;
  173. // [self setBackgroundImage:[UIImage imageWithColor:HexColorFromRGBA(0x5669EF,0.06f) size:CGSizeMake(KScreenWidth, NavBarHeight)] forBarMetrics:(UIBarMetricsDefault)];
  174. //}
  175. ///// 伯爵
  176. //- (void)setEarlBar{
  177. // self.translucent = NO;
  178. // [self setBackgroundImage:[UIImage imageWithColor:HexColorFromRGBA(0xFFB39A,0.06f) size:CGSizeMake(KScreenWidth, NavBarHeight)] forBarMetrics:(UIBarMetricsDefault)];
  179. //}
  180. ///// 公爵
  181. //- (void)setDukeBar{
  182. // self.translucent = NO;
  183. // [self setBackgroundImage:[UIImage imageWithColor:HexColorFromRGBA(0xFF6DBB,0.06f) size:CGSizeMake(KScreenWidth, NavBarHeight)] forBarMetrics:(UIBarMetricsDefault)];
  184. //}
  185. ///// 国王
  186. //- (void)setKingBar{
  187. // self.translucent = NO;
  188. // [self setBackgroundImage:[UIImage imageWithColor:HexColorFromRGBA(0xFF6DBB,0.06f) size:CGSizeMake(KScreenWidth, NavBarHeight)] forBarMetrics:(UIBarMetricsDefault)];
  189. //}
  190. ///// 皇帝
  191. //- (void)setEmperorBar{
  192. // self.translucent = NO;
  193. // [self setBackgroundImage:[UIImage imageWithColor:HexColorFromRGBA(0xFF6DBB,0.06f) size:CGSizeMake(KScreenWidth, NavBarHeight)] forBarMetrics:(UIBarMetricsDefault)];
  194. //}
  195. @end