2
0

StyleDIY.m 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. //
  2. // DemoListViewModel.m
  3. // LBXScanDemo
  4. //
  5. // Created by lbxia on 2017/4/1.
  6. // Copyright © 2017年 lbx. All rights reserved.
  7. //
  8. #import "StyleDIY.h"
  9. #import <AVFoundation/AVFoundation.h>
  10. @implementation StyleDIY
  11. #pragma mark -模仿qq界面
  12. + (LBXScanViewStyle*)qqStyle
  13. {
  14. //设置扫码区域参数设置
  15. //创建参数对象
  16. LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
  17. //矩形区域中心上移,默认中心点为屏幕中心点
  18. style.centerUpOffset = 44;
  19. //扫码框周围4个角的类型,设置为外挂式
  20. style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_Outer;
  21. //扫码框周围4个角绘制的线条宽度
  22. style.photoframeLineW = 6;
  23. //扫码框周围4个角的宽度
  24. style.photoframeAngleW = 24;
  25. //扫码框周围4个角的高度
  26. style.photoframeAngleH = 24;
  27. //扫码框内 动画类型 --线条上下移动
  28. style.anmiationStyle = LBXScanViewAnimationStyle_LineMove;
  29. //线条上下移动图片
  30. style.animationImage = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_light_green"];
  31. style.notRecoginitonArea = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
  32. return style;
  33. }
  34. #pragma mark --模仿支付宝
  35. + (LBXScanViewStyle*)ZhiFuBaoStyle
  36. {
  37. //设置扫码区域参数
  38. LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
  39. style.centerUpOffset = 60;
  40. style.xScanRetangleOffset = 30;
  41. if ([UIScreen mainScreen].bounds.size.height <= 480 )
  42. {
  43. //3.5inch 显示的扫码缩小
  44. style.centerUpOffset = 40;
  45. style.xScanRetangleOffset = 20;
  46. }
  47. style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_Inner;
  48. style.photoframeLineW = 2.0;
  49. style.photoframeAngleW = 16;
  50. style.photoframeAngleH = 16;
  51. style.isNeedShowRetangle = NO;
  52. style.anmiationStyle = LBXScanViewAnimationStyle_NetGrid;
  53. style.notRecoginitonArea = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
  54. //使用的支付宝里面网格图片
  55. UIImage *imgFullNet = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_full_net"];
  56. style.animationImage = imgFullNet;
  57. return style;
  58. }
  59. #pragma mark -无边框,内嵌4个角
  60. + (LBXScanViewStyle*)InnerStyle
  61. {
  62. //设置扫码区域参数
  63. LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
  64. style.centerUpOffset = 44;
  65. style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_Inner;
  66. style.photoframeLineW = 3;
  67. style.photoframeAngleW = 18;
  68. style.photoframeAngleH = 18;
  69. style.isNeedShowRetangle = NO;
  70. style.anmiationStyle = LBXScanViewAnimationStyle_LineMove;
  71. //qq里面的线条图片
  72. UIImage *imgLine = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_light_green"];
  73. style.animationImage = imgLine;
  74. style.notRecoginitonArea = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
  75. return style;
  76. }
  77. #pragma mark -无边框,内嵌4个角
  78. + (LBXScanViewStyle*)weixinStyle
  79. {
  80. //设置扫码区域参数
  81. LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
  82. style.centerUpOffset = 44;
  83. style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_Inner;
  84. style.photoframeLineW = 2;
  85. style.photoframeAngleW = 18;
  86. style.photoframeAngleH = 18;
  87. style.isNeedShowRetangle = YES;
  88. style.anmiationStyle = LBXScanViewAnimationStyle_LineMove;
  89. style.colorAngle = [UIColor colorWithRed:0./255 green:200./255. blue:20./255. alpha:1.0];
  90. //qq里面的线条图片
  91. UIImage *imgLine = [UIImage imageNamed:@"CodeScan.bundle/qrcode_Scan_weixin_Line"];
  92. style.animationImage = imgLine;
  93. style.notRecoginitonArea = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
  94. return style;
  95. }
  96. #pragma mark -框内区域识别
  97. + (LBXScanViewStyle*)recoCropRect
  98. {
  99. //设置扫码区域参数
  100. LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
  101. style.centerUpOffset = 44;
  102. style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_On;
  103. style.photoframeLineW = 6;
  104. style.photoframeAngleW = 24;
  105. style.photoframeAngleH = 24;
  106. style.isNeedShowRetangle = YES;
  107. style.anmiationStyle = LBXScanViewAnimationStyle_NetGrid;
  108. //矩形框离左边缘及右边缘的距离
  109. style.xScanRetangleOffset = 80;
  110. //使用的支付宝里面网格图片
  111. UIImage *imgPartNet = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_part_net"];
  112. style.animationImage = imgPartNet;
  113. style.notRecoginitonArea = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
  114. return style;
  115. }
  116. #pragma mark -4个角在矩形框线上,网格动画
  117. + (LBXScanViewStyle*)OnStyle
  118. {
  119. //设置扫码区域参数
  120. LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
  121. style.centerUpOffset = 44;
  122. style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_On;
  123. style.photoframeLineW = 6;
  124. style.photoframeAngleW = 24;
  125. style.photoframeAngleH = 24;
  126. style.isNeedShowRetangle = YES;
  127. style.anmiationStyle = LBXScanViewAnimationStyle_NetGrid;
  128. //使用的支付宝里面网格图片
  129. UIImage *imgPartNet = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_part_net"];
  130. style.animationImage = imgPartNet;
  131. style.notRecoginitonArea = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
  132. return style;
  133. }
  134. #pragma mark -自定义4个角及矩形框颜色
  135. + (LBXScanViewStyle*)changeColor
  136. {
  137. //设置扫码区域参数
  138. LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
  139. style.centerUpOffset = 44;
  140. //扫码框周围4个角的类型设置为在框的上面
  141. style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_On;
  142. //扫码框周围4个角绘制线宽度
  143. style.photoframeLineW = 6;
  144. //扫码框周围4个角的宽度
  145. style.photoframeAngleW = 24;
  146. //扫码框周围4个角的高度
  147. style.photoframeAngleH = 24;
  148. //显示矩形框
  149. style.isNeedShowRetangle = YES;
  150. //动画类型:网格形式,模仿支付宝
  151. style.anmiationStyle = LBXScanViewAnimationStyle_NetGrid;
  152. style.animationImage = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_part_net"];;
  153. //码框周围4个角的颜色
  154. style.colorAngle = [UIColor colorWithRed:65./255. green:174./255. blue:57./255. alpha:1.0];
  155. //矩形框颜色
  156. style.colorRetangleLine = [UIColor colorWithRed:247/255. green:202./255. blue:15./255. alpha:1.0];
  157. //非矩形框区域颜色
  158. style.notRecoginitonArea = [UIColor colorWithRed:247./255. green:202./255 blue:15./255 alpha:0.2];
  159. return style;
  160. }
  161. #pragma mark -改变扫码区域位置
  162. + (LBXScanViewStyle*)changeSize
  163. {
  164. //设置扫码区域参数
  165. LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
  166. //矩形框向上移动
  167. style.centerUpOffset = 60;
  168. //矩形框离左边缘及右边缘的距离
  169. style.xScanRetangleOffset = 100;
  170. style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_On;
  171. style.photoframeLineW = 6;
  172. style.photoframeAngleW = 24;
  173. style.photoframeAngleH = 24;
  174. style.isNeedShowRetangle = YES;
  175. style.anmiationStyle = LBXScanViewAnimationStyle_LineMove;
  176. //qq里面的线条图片
  177. UIImage *imgLine = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_light_green"];
  178. style.animationImage = imgLine;
  179. style.notRecoginitonArea = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
  180. return style;
  181. }
  182. #pragma mark -非正方形,可以用在扫码条形码界面
  183. + (UIImage*) createImageWithColor: (UIColor*) color
  184. {
  185. CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
  186. UIGraphicsBeginImageContext(rect.size);
  187. CGContextRef context = UIGraphicsGetCurrentContext();
  188. CGContextSetFillColorWithColor(context, [color CGColor]);
  189. CGContextFillRect(context, rect);
  190. UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
  191. UIGraphicsEndImageContext();
  192. return theImage;
  193. }
  194. + (LBXScanViewStyle*)notSquare
  195. {
  196. //设置扫码区域参数
  197. LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
  198. style.centerUpOffset = 44;
  199. style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_Inner;
  200. style.photoframeLineW = 4;
  201. style.photoframeAngleW = 28;
  202. style.photoframeAngleH = 16;
  203. style.isNeedShowRetangle = NO;
  204. style.anmiationStyle = LBXScanViewAnimationStyle_LineStill;
  205. style.animationImage = [[self class] createImageWithColor:[UIColor redColor]];
  206. //非正方形
  207. //设置矩形宽高比
  208. style.whRatio = 4.3/2.18;
  209. //离左边和右边距离
  210. style.xScanRetangleOffset = 30;
  211. style.notRecoginitonArea = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
  212. return style;
  213. }
  214. @end