Commit 9a826d8bf75a122a8c727081eb7e9430a060a32c

Authored by zhangxiaowen
1 parent 77bd4605

no message

CNLiveQrCodeModule.podspec
... ... @@ -97,6 +97,9 @@ TODO: 网家家-二维码模块.
97 97 # 分类
98 98 s.dependency 'CNLiveCategory'
99 99  
  100 + # 自定义控件
  101 + s.dependency 'CNLiveCustomControl'
  102 +
100 103 s.static_framework = true
101 104  
102 105 end
... ...
CNLiveQrCodeModule/Classes/Controller/CNLiveGenerateQrCodeController.m
... ... @@ -14,13 +14,13 @@
14 14 #import <Masonry/Masonry.h>
15 15 #import <SDWebImage/SDWebImage.h>
16 16 #import "CNLiveCategory.h"
  17 +#import "CNLiveNavigationBar.h"
17 18  
18   -#import "CNLiveQrCodeNavigationBar.h"
19 19 #import "CNLiveGenerateCodeView.h"
20 20 #import "CNLiveScanQrCodeController.h"
21 21  
22   -@interface CNLiveGenerateQrCodeController ()<CNLiveQrCodeNavigationBarDelegate,QMUIAlertControllerDelegate>
23   -@property (nonatomic, strong) CNLiveQrCodeNavigationBar *navigationBar;
  22 +@interface CNLiveGenerateQrCodeController ()<QMUIAlertControllerDelegate>
  23 +@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
24 24 @property (nonatomic, strong) UIImageView *bgView;
25 25 @property (nonatomic, strong) CNLiveGenerateCodeView *qrCodeView;
26 26  
... ... @@ -155,60 +155,6 @@ static const CGFloat timeValue = 1.5;
155 155  
156 156 }
157 157  
158   -- (void)navigationBar:(CNLiveQrCodeNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
159   - if ([actionEvents isEqualToString:@"1"]) {
160   - [self goBack];
161   - }
162   - else if ([actionEvents isEqualToString:@"2"]){
163   - self.navigationBar.right.userInteractionEnabled = NO;
164   - __weak typeof(self) weakSelf = self;
165   - QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"保存图片" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
166   - __strong typeof(weakSelf) strongSelf = weakSelf;
167   - if(!strongSelf) return ;
168   - [strongSelf getPHAuthorizationStatus:^{
169   - UIImage *image = [strongSelf generateImage:strongSelf.qrCodeView];
170   - [QMUITips showLoadingInView:strongSelf.view];
171   - [strongSelf saveImage:image];
172   - [QMUITips hideAllTipsInView:strongSelf.view];
173   - }];
174   - self.navigationBar.right.userInteractionEnabled = YES;
175   -
176   - }];
177   - QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"扫描二维码" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
178   - __strong typeof(weakSelf) strongSelf = weakSelf;
179   - if(!strongSelf) return ;
180   - CNLiveScanQrCodeController *vc = [[CNLiveScanQrCodeController alloc]init];
181   - [strongSelf.navigationController pushViewController:vc animated:YES];
182   -
183   - self.navigationBar.right.userInteractionEnabled = YES;
184   - }];
185   - QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
186   - __strong typeof(weakSelf) strongSelf = weakSelf;
187   - if(!strongSelf) return ;
188   - self.navigationBar.right.userInteractionEnabled = YES;
189   -
190   - }];
191   -
192   - QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet];
193   - alertController.delegate = self;
194   - [alertController addAction:action1];
195   - [alertController addAction:action2];
196   - [alertController addAction:cancel];
197   -
198   - NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
199   -
200   - titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
201   -
202   - NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
203   - cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
204   -
205   - action1.buttonAttributes = titleAttributs;
206   - action2.buttonAttributes = titleAttributs;
207   - cancel.buttonAttributes = cancelAttributs;
208   -
209   - [alertController showWithAnimated:YES];
210   - }
211   -}
212 158 - (void)didHideAlertController:(QMUIAlertController *)alertController{
213 159 self.navigationBar.right.userInteractionEnabled = YES;
214 160  
... ... @@ -230,13 +176,75 @@ static const CGFloat timeValue = 1.5;
230 176 }
231 177 return _qrCodeView;
232 178 }
233   -- (CNLiveQrCodeNavigationBar *)navigationBar {
  179 +- (CNLiveNavigationBar *)navigationBar {
234 180 if (!_navigationBar) {
235   - _navigationBar = [[CNLiveQrCodeNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)];
236   - _navigationBar.delegate = self;
  181 + _navigationBar = [CNLiveNavigationBar navigationBar];
  182 + _navigationBar.backgroundColor = [UIColor clearColor];
  183 + UIImage *image1 = [self getImageWithImageName:@"cnlive_back_white_b" bundleName:@"CNLiveCustomControl" targetClass:[CNLiveNavigationBar class]];
  184 + _navigationBar.leftImage = image1;
  185 +
237 186 _navigationBar.title.text = @"生成二维码";
238   - UIImage *image2 = [self getImageWithImageName:@"mine_code_more" bundleName:@"CNLiveQrCodeModule" targetClass:[self class]];
239   - [_navigationBar.right setImage:[image2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
  187 + _navigationBar.title.textColor = [UIColor whiteColor];
  188 + _navigationBar.lineHidden = YES;
  189 +
  190 + UIImage *image2 = [self getImageWithImageName:@"cnlive_white_more" bundleName:@"CNLiveCustomControl" targetClass:[CNLiveNavigationBar class]];
  191 + _navigationBar.rightImage = image2;
  192 +
  193 + __weak typeof(self) weakSelf = self;
  194 + _navigationBar.onClickLeftButton = ^{
  195 + __strong typeof(weakSelf) strongSelf = weakSelf;
  196 + if(!strongSelf) return ;
  197 + [strongSelf goBack];
  198 + };
  199 + _navigationBar.onClickRightButton = ^{
  200 + _navigationBar.right.userInteractionEnabled = NO;
  201 + __weak typeof(self) weakSelf = self;
  202 + QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"保存图片" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  203 + __strong typeof(weakSelf) strongSelf = weakSelf;
  204 + if(!strongSelf) return ;
  205 + [strongSelf getPHAuthorizationStatus:^{
  206 + UIImage *image = [strongSelf generateImage:strongSelf.qrCodeView];
  207 + [QMUITips showLoadingInView:strongSelf.view];
  208 + [strongSelf saveImage:image];
  209 + [QMUITips hideAllTipsInView:strongSelf.view];
  210 + }];
  211 + _navigationBar.right.userInteractionEnabled = YES;
  212 +
  213 + }];
  214 + QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"扫描二维码" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  215 + __strong typeof(weakSelf) strongSelf = weakSelf;
  216 + if(!strongSelf) return ;
  217 + CNLiveScanQrCodeController *vc = [[CNLiveScanQrCodeController alloc]init];
  218 + [strongSelf.navigationController pushViewController:vc animated:YES];
  219 +
  220 + _navigationBar.right.userInteractionEnabled = YES;
  221 + }];
  222 + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  223 + __strong typeof(weakSelf) strongSelf = weakSelf;
  224 + if(!strongSelf) return ;
  225 + _navigationBar.right.userInteractionEnabled = YES;
  226 +
  227 + }];
  228 +
  229 + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet];
  230 + alertController.delegate = self;
  231 + [alertController addAction:action1];
  232 + [alertController addAction:action2];
  233 + [alertController addAction:cancel];
  234 +
  235 + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  236 +
  237 + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  238 +
  239 + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  240 + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  241 +
  242 + action1.buttonAttributes = titleAttributs;
  243 + action2.buttonAttributes = titleAttributs;
  244 + cancel.buttonAttributes = cancelAttributs;
  245 +
  246 + [alertController showWithAnimated:YES];
  247 + };
240 248 }
241 249 return _navigationBar;
242 250 }
... ...
CNLiveQrCodeModule/Classes/Controller/CNLiveGroupQrCodeController.m
... ... @@ -14,13 +14,12 @@
14 14 //#import "CNLiveShareManager.h"
15 15 //#import "CNLiveShareToolDefine.h"
16 16 #import "CNLiveCategory.h"
  17 +#import "CNLiveNavigationBar.h"
17 18  
18   -#import "CNLiveQrCodeNavigationBar.h"
19 19 #import "CNLiveGroupQrcodeView.h"
20   -#import "CNLiveQrCodeNavigationBar.h"
21 20  
22   -@interface CNLiveGroupQrCodeController ()<CNLiveQrCodeNavigationBarDelegate>
23   -@property (nonatomic, strong) CNLiveQrCodeNavigationBar *navigationBar;
  21 +@interface CNLiveGroupQrCodeController ()
  22 +@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
24 23 @property (nonatomic, strong) CNLiveGroupQrCodeView *groupView;
25 24 @property (nonatomic, strong) UIButton *save;
26 25 @property (nonatomic, strong) UIButton *share;
... ... @@ -74,24 +73,17 @@ static const CGFloat timeValue = 1.5;
74 73 }
75 74 */
76 75  
77   -#pragma mark - 代理
78   -- (void)navigationBar:(CNLiveQrCodeNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
79   - if ([actionEvents isEqualToString:@"1"]) {
80   - [self goBack];
81   - }
82   -}
83   -
84 76 #pragma mark - 懒加载
85   -- (CNLiveQrCodeNavigationBar *)navigationBar {
  77 +- (CNLiveNavigationBar *)navigationBar {
86 78 if (!_navigationBar) {
87   - _navigationBar = [[CNLiveQrCodeNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)];
88   - _navigationBar.backgroundColor = [UIColor whiteColor];
89   - _navigationBar.delegate = self;
90   - UIImage *image = [self getImageWithImageName:@"code_back_black_b" bundleName:@"CNLiveQrCodeModule" targetClass:[CNLiveGroupQrCodeController class]];
91   - [_navigationBar.left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
  79 + _navigationBar = [CNLiveNavigationBar navigationBar];
92 80 _navigationBar.title.text = @"群二维码名片";
93   - _navigationBar.title.textColor = [UIColor blackColor];
94   - _navigationBar.right = nil;
  81 + __weak typeof(self) weakSelf = self;
  82 + _navigationBar.onClickLeftButton = ^{
  83 + __strong typeof(weakSelf) strongSelf = weakSelf;
  84 + if(!strongSelf) return ;
  85 + [strongSelf goBack];
  86 + };
95 87 }
96 88 return _navigationBar;
97 89 }
... ...
CNLiveQrCodeModule/Classes/Controller/CNLiveMyQrCodeController.m
... ... @@ -14,13 +14,13 @@
14 14 #import <Masonry/Masonry.h>
15 15 #import <SDWebImage/SDWebImage.h>
16 16 #import "CNLiveCategory.h"
  17 +#import "CNLiveNavigationBar.h"
17 18  
18   -#import "CNLiveQrCodeNavigationBar.h"
19 19 #import "CNLiveMyQrCodeView.h"
20 20 #import "CNLiveScanQrCodeController.h"
21 21  
22   -@interface CNLiveMyQrCodeController ()<CNLiveQrCodeNavigationBarDelegate,QMUIAlertControllerDelegate>
23   -@property (nonatomic, strong) CNLiveQrCodeNavigationBar *navigationBar;
  22 +@interface CNLiveMyQrCodeController ()<QMUIAlertControllerDelegate>
  23 +@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
24 24 @property (nonatomic, strong) UIImageView *bgView;
25 25 @property (nonatomic, strong) CNLiveMyQrCodeView *qrCodeView;
26 26  
... ... @@ -153,73 +153,14 @@ static const CGFloat timeValue = 1.5;
153 153  
154 154 }
155 155  
156   -- (void)navigationBar:(CNLiveQrCodeNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
157   - if ([actionEvents isEqualToString:@"1"]) {
158   - [self goBack];
159   - }
160   - else if ([actionEvents isEqualToString:@"2"]){
161   - self.navigationBar.right.userInteractionEnabled = NO;
162   - __weak typeof(self) weakSelf = self;
163   - QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"保存图片" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
164   - __strong typeof(weakSelf) strongSelf = weakSelf;
165   - if(!strongSelf) return ;
166   - [strongSelf getPHAuthorizationStatus:^{
167   - UIImage *image = [strongSelf generateImage:strongSelf.qrCodeView];
168   - [QMUITips showLoadingInView:strongSelf.view];
169   - [strongSelf saveImage:image];
170   - [QMUITips hideAllTipsInView:strongSelf.view];
171   - }];
172   - self.navigationBar.right.userInteractionEnabled = YES;
173   -
174   - }];
175   - QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"扫描二维码" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
176   - __strong typeof(weakSelf) strongSelf = weakSelf;
177   - if(!strongSelf) return ;
178   - if(strongSelf.isScanCode){
179   - [strongSelf.navigationController popViewControllerAnimated:YES];
180   - }else{
181   - CNLiveScanQrCodeController *vc = [[CNLiveScanQrCodeController alloc]init];
182   - vc.isMyCode = YES;
183   - [strongSelf.navigationController pushViewController:vc animated:YES];
184   - }
185   - self.navigationBar.right.userInteractionEnabled = YES;
186   - }];
187   - QMUIAlertAction *action3 = [QMUIAlertAction actionWithTitle:@"重置二维码" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
188   - __strong typeof(weakSelf) strongSelf = weakSelf;
189   - if(!strongSelf) return ;
190   - [strongSelf.qrCodeView generateQRCode:@"reset"];
191   - self.navigationBar.right.userInteractionEnabled = YES;
192   -
193   - }];
194   - QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
195   - __strong typeof(weakSelf) strongSelf = weakSelf;
196   - if(!strongSelf) return ;
197   - self.navigationBar.right.userInteractionEnabled = YES;
198   -
199   - }];
200   -
201   - QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet];
202   - alertController.delegate = self;
203   - [alertController addAction:action1];
204   - [alertController addAction:action2];
205   - [alertController addAction:action3];
206   - [alertController addAction:cancel];
207   -
208   - NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
209   -
210   - titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
211   -
212   - NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
213   - cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
214   -
215   - action1.buttonAttributes = titleAttributs;
216   - action2.buttonAttributes = titleAttributs;
217   - action3.buttonAttributes = titleAttributs;
218   - cancel.buttonAttributes = cancelAttributs;
219   -
220   - [alertController showWithAnimated:YES];
221   - }
222   -}
  156 +//- (void)navigationBar:(CNLiveQrCodeNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
  157 +// if ([actionEvents isEqualToString:@"1"]) {
  158 +// [self goBack];
  159 +// }
  160 +// else if ([actionEvents isEqualToString:@"2"]){
  161 +//
  162 +// }
  163 +//}
223 164 - (void)didHideAlertController:(QMUIAlertController *)alertController{
224 165 self.navigationBar.right.userInteractionEnabled = YES;
225 166  
... ... @@ -243,13 +184,88 @@ static const CGFloat timeValue = 1.5;
243 184 }
244 185 return _qrCodeView;
245 186 }
246   -- (CNLiveQrCodeNavigationBar *)navigationBar {
  187 +- (CNLiveNavigationBar *)navigationBar {
247 188 if (!_navigationBar) {
248   - _navigationBar = [[CNLiveQrCodeNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)];
249   - _navigationBar.delegate = self;
  189 + _navigationBar = [CNLiveNavigationBar navigationBar];
  190 + _navigationBar.backgroundColor = [UIColor clearColor];
  191 + UIImage *image1 = [self getImageWithImageName:@"cnlive_back_white_b" bundleName:@"CNLiveCustomControl" targetClass:[CNLiveNavigationBar class]];
  192 + _navigationBar.leftImage = image1;
  193 +
250 194 _navigationBar.title.text = @"我的二维码";
251   - UIImage *image2 = [self getImageWithImageName:@"mine_code_more" bundleName:@"CNLiveQrCodeModule" targetClass:[CNLiveMyQrCodeController class]];
252   - [_navigationBar.right setImage:[image2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
  195 + _navigationBar.title.textColor = [UIColor whiteColor];
  196 + _navigationBar.lineHidden = YES;
  197 +
  198 + UIImage *image2 = [self getImageWithImageName:@"cnlive_white_more" bundleName:@"CNLiveCustomControl" targetClass:[CNLiveNavigationBar class]];
  199 + _navigationBar.rightImage = image2;
  200 +
  201 + __weak typeof(self) weakSelf = self;
  202 + _navigationBar.onClickLeftButton = ^{
  203 + __strong typeof(weakSelf) strongSelf = weakSelf;
  204 + if(!strongSelf) return ;
  205 + [strongSelf goBack];
  206 + };
  207 + _navigationBar.onClickRightButton = ^{
  208 + self.navigationBar.right.userInteractionEnabled = NO;
  209 + __weak typeof(self) weakSelf = self;
  210 + QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"保存图片" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  211 + __strong typeof(weakSelf) strongSelf = weakSelf;
  212 + if(!strongSelf) return ;
  213 + [strongSelf getPHAuthorizationStatus:^{
  214 + UIImage *image = [strongSelf generateImage:strongSelf.qrCodeView];
  215 + [QMUITips showLoadingInView:strongSelf.view];
  216 + [strongSelf saveImage:image];
  217 + [QMUITips hideAllTipsInView:strongSelf.view];
  218 + }];
  219 + self.navigationBar.right.userInteractionEnabled = YES;
  220 +
  221 + }];
  222 + QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"扫描二维码" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  223 + __strong typeof(weakSelf) strongSelf = weakSelf;
  224 + if(!strongSelf) return ;
  225 + if(strongSelf.isScanCode){
  226 + [strongSelf.navigationController popViewControllerAnimated:YES];
  227 + }else{
  228 + CNLiveScanQrCodeController *vc = [[CNLiveScanQrCodeController alloc]init];
  229 + vc.isMyCode = YES;
  230 + [strongSelf.navigationController pushViewController:vc animated:YES];
  231 + }
  232 + self.navigationBar.right.userInteractionEnabled = YES;
  233 + }];
  234 + QMUIAlertAction *action3 = [QMUIAlertAction actionWithTitle:@"重置二维码" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  235 + __strong typeof(weakSelf) strongSelf = weakSelf;
  236 + if(!strongSelf) return ;
  237 + [strongSelf.qrCodeView generateQRCode:@"reset"];
  238 + self.navigationBar.right.userInteractionEnabled = YES;
  239 +
  240 + }];
  241 + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  242 + __strong typeof(weakSelf) strongSelf = weakSelf;
  243 + if(!strongSelf) return ;
  244 + self.navigationBar.right.userInteractionEnabled = YES;
  245 +
  246 + }];
  247 +
  248 + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet];
  249 + alertController.delegate = self;
  250 + [alertController addAction:action1];
  251 + [alertController addAction:action2];
  252 + [alertController addAction:action3];
  253 + [alertController addAction:cancel];
  254 +
  255 + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  256 +
  257 + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  258 +
  259 + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  260 + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  261 +
  262 + action1.buttonAttributes = titleAttributs;
  263 + action2.buttonAttributes = titleAttributs;
  264 + action3.buttonAttributes = titleAttributs;
  265 + cancel.buttonAttributes = cancelAttributs;
  266 +
  267 + [alertController showWithAnimated:YES];
  268 + };
253 269 }
254 270 return _navigationBar;
255 271 }
... ...
CNLiveQrCodeModule/Classes/Controller/CNLiveScanQrCodeController.m
... ... @@ -15,14 +15,14 @@
15 15 #import "CNLiveCategory.h"
16 16  
17 17 #import "CNLiveMyQrCodeController.h"
18   -#import "CNLiveQrCodeNavigationBar.h"
  18 +#import "CNLiveNavigationBar.h"
19 19  
20 20 #import "CNLiveScanResultController.h"
21 21  
22   -@interface CNLiveScanQrCodeController ()<CNLiveQrCodeNavigationBarDelegate>{
  22 +@interface CNLiveScanQrCodeController (){
23 23 SGQRCodeObtain *obtain;
24 24 }
25   -@property (nonatomic, strong) CNLiveQrCodeNavigationBar *navigationBar;
  25 +@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
26 26 @property (nonatomic, strong) SGQRCodeScanView *scanView;
27 27 @property (nonatomic, strong) UIButton *flashlightBtn;//手电筒
28 28 @property (nonatomic, assign) BOOL isSelected;//是否打开手电筒
... ... @@ -245,44 +245,55 @@ static const CGFloat timeValue = 1.5;
245 245 }
246 246  
247 247 #pragma mark - 选择图片识别二维码
248   -- (void)navigationBar:(CNLiveQrCodeNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
249   - if ([actionEvents isEqualToString:@"1"]) {
250   - [self goBack];
251   - }else if([actionEvents isEqualToString:@"2"]){
252   - _navigationBar.right.userInteractionEnabled = NO;
253   - // 从相册中读取二维码
254   - [obtain establishAuthorizationQRCodeObtainAlbumWithController:nil];
255   - if (obtain.isPHAuthorization == YES) {
256   - [self.scanView removeTimer];
257   - }
258   -
259   - __weak typeof(self) weakSelf = self;
260   - [obtain setBlockWithQRCodeObtainAlbumDidCancelImagePickerController:^(SGQRCodeObtain *obtain) {
261   - __strong typeof(weakSelf) strongSelf = weakSelf;
262   - if(!strongSelf) return ;
263   - strongSelf.navigationBar.right.userInteractionEnabled = YES;
264   - }];
265   - [obtain setBlockWithQRCodeObtainAlbumResult:^(SGQRCodeObtain *obtain, NSString *result) {
266   - __strong typeof(weakSelf) strongSelf = weakSelf;
267   - if(!strongSelf) return ;
268   - strongSelf.navigationBar.right.userInteractionEnabled = YES;
269   - if (result == nil) {
270   - NSLog(@"暂未识别出二维码");
271   - [QMUITips showError:@"暂未识别出二维码" inView:strongSelf.view hideAfterDelay:timeValue];
272   -
273   - } else {
274   - [strongSelf handleResult:result];
275   - }
276   - }];
277   - }
278   -}
279 248 #pragma mark - 懒加载
280   -- (CNLiveQrCodeNavigationBar *)navigationBar {
  249 +- (CNLiveNavigationBar *)navigationBar {
281 250 if (!_navigationBar) {
282   - _navigationBar = [[CNLiveQrCodeNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)];
283   - _navigationBar.delegate = self;
  251 + _navigationBar = [CNLiveNavigationBar navigationBar];
  252 + _navigationBar.backgroundColor = [UIColor clearColor];
  253 + UIImage *image = [self getImageWithImageName:@"cnlive_back_white_b" bundleName:@"CNLiveCustomControl" targetClass:[CNLiveNavigationBar class]];
  254 + _navigationBar.leftImage = image;
  255 +
284 256 _navigationBar.title.text = @"扫一扫";
285   - [_navigationBar.right setTitle:@"相册" forState:UIControlStateNormal];
  257 + _navigationBar.title.textColor = [UIColor whiteColor];
  258 +
  259 + _navigationBar.rightTitle = @"相册";
  260 + [_navigationBar.right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  261 +
  262 + _navigationBar.lineHidden = YES;
  263 +
  264 + __weak typeof(self) weakSelf = self;
  265 + _navigationBar.onClickLeftButton = ^{
  266 + __strong typeof(weakSelf) strongSelf = weakSelf;
  267 + if(!strongSelf) return ;
  268 + [strongSelf goBack];
  269 + };
  270 + _navigationBar.onClickRightButton = ^{
  271 + _navigationBar.right.userInteractionEnabled = NO;
  272 + // 从相册中读取二维码
  273 + [obtain establishAuthorizationQRCodeObtainAlbumWithController:nil];
  274 + if (obtain.isPHAuthorization == YES) {
  275 + [self.scanView removeTimer];
  276 + }
  277 +
  278 + __weak typeof(self) weakSelf = self;
  279 + [obtain setBlockWithQRCodeObtainAlbumDidCancelImagePickerController:^(SGQRCodeObtain *obtain) {
  280 + __strong typeof(weakSelf) strongSelf = weakSelf;
  281 + if(!strongSelf) return ;
  282 + strongSelf.navigationBar.right.userInteractionEnabled = YES;
  283 + }];
  284 + [obtain setBlockWithQRCodeObtainAlbumResult:^(SGQRCodeObtain *obtain, NSString *result) {
  285 + __strong typeof(weakSelf) strongSelf = weakSelf;
  286 + if(!strongSelf) return ;
  287 + strongSelf.navigationBar.right.userInteractionEnabled = YES;
  288 + if (result == nil) {
  289 + NSLog(@"暂未识别出二维码");
  290 + [QMUITips showError:@"暂未识别出二维码" inView:strongSelf.view hideAfterDelay:timeValue];
  291 +
  292 + } else {
  293 + [strongSelf handleResult:result];
  294 + }
  295 + }];
  296 + };
286 297 }
287 298 return _navigationBar;
288 299 }
... ...
CNLiveQrCodeModule/Classes/Controller/CNLiveScanResultController.m
... ... @@ -10,11 +10,11 @@
10 10 #import "QMUIKit.h"
11 11 #import "CNLiveCategory.h"
12 12  
13   -#import "CNLiveQrCodeNavigationBar.h"
  13 +#import "CNLiveNavigationBar.h"
14 14 #import "CNLiveWebView.h"
15 15  
16   -@interface CNLiveScanResultController () <CNLiveQrCodeNavigationBarDelegate, CNLiveWebViewDelegate>
17   -@property (nonatomic, strong) CNLiveQrCodeNavigationBar *navigationBar;
  16 +@interface CNLiveScanResultController () <CNLiveWebViewDelegate>
  17 +@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;
18 18 @property (nonatomic, strong) CNLiveWebView *webView;
19 19  
20 20 @end
... ... @@ -50,12 +50,6 @@
50 50 }
51 51  
52 52 #pragma mark - 代理
53   -- (void)navigationBar:(CNLiveQrCodeNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
54   - if ([actionEvents isEqualToString:@"1"]) {
55   - [self goBack];
56   - }
57   -}
58   -
59 53 - (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url {
60 54 NSLog(@"didFinishLoad");
61 55 if(webView.navigationItemTitle.length != 0){
... ... @@ -72,16 +66,15 @@
72 66 }
73 67  
74 68 #pragma mark - 懒加载
75   -- (CNLiveQrCodeNavigationBar *)navigationBar {
  69 +- (CNLiveNavigationBar *)navigationBar {
76 70 if (!_navigationBar) {
77   - _navigationBar = [[CNLiveQrCodeNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)];
78   - _navigationBar.delegate = self;
79   - _navigationBar.title.textColor = [UIColor blackColor];
80   - _navigationBar.delegate = self;
81   -
82   - UIImage *image = [self getImageWithImageName:@"code_back_black_b" bundleName:@"CNLiveQrCodeModule" targetClass:[CNLiveScanResultController class]];
83   - [_navigationBar.left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
84   - _navigationBar.right = nil;
  71 + _navigationBar = [[CNLiveNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)];
  72 + __weak typeof(self) weakSelf = self;
  73 + _navigationBar.onClickLeftButton = ^{
  74 + __strong typeof(weakSelf) strongSelf = weakSelf;
  75 + if(!strongSelf) return ;
  76 + [strongSelf goBack];
  77 + };
85 78  
86 79 }
87 80 return _navigationBar;
... ...
CNLiveQrCodeModule/Classes/View/CNLiveQrCodeNavigationBar.h deleted 100644 → 0
1   -//
2   -// CNLiveQrCodeNavigationBar.h
3   -// CNLiveQrCodeModule
4   -//
5   -// Created by 153993236@qq.com on 11/12/2019.
6   -// Copyright © 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -#import <UIKit/UIKit.h>
10   -
11   -NS_ASSUME_NONNULL_BEGIN
12   -@class CNLiveQrCodeNavigationBar;
13   -
14   -@protocol CNLiveQrCodeNavigationBarDelegate <NSObject>
15   -- (void)navigationBar:(CNLiveQrCodeNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents;
16   -
17   -@end
18   -
19   -@interface CNLiveQrCodeNavigationBar : UIView
20   -@property (nonatomic, weak) id<CNLiveQrCodeNavigationBarDelegate> delegate;
21   -@property (nonatomic, strong) UIView *navView;
22   -@property (nonatomic, strong) UIButton *left;
23   -@property (nonatomic, strong) UILabel *title;
24   -@property (nonatomic, strong, nullable) UIButton *right;
25   -
26   -@end
27   -
28   -NS_ASSUME_NONNULL_END
CNLiveQrCodeModule/Classes/View/CNLiveQrCodeNavigationBar.m deleted 100644 → 0
1   -//
2   -// CNLiveQrCodeNavigationBar.m
3   -// CNLiveQrCodeModule
4   -//
5   -// Created by 153993236@qq.com on 11/12/2019.
6   -// Copyright © 2019 153993236@qq.com. All rights reserved.
7   -//
8   -
9   -#import "CNLiveQrCodeNavigationBar.h"
10   -#import "QMUIKit.h"
11   -#import "CNLiveCategory.h"
12   -
13   -@interface CNLiveQrCodeNavigationBar ()
14   -
15   -@end
16   -
17   -@implementation CNLiveQrCodeNavigationBar
18   -static const NSInteger margin = 15;
19   -
20   -- (instancetype)initWithFrame:(CGRect)frame{
21   - self = [super initWithFrame:frame];
22   - if(self){
23   - self.userInteractionEnabled = YES;
24   - self.backgroundColor = [UIColor clearColor];
25   - [self createSubViews];
26   - }
27   - return self;
28   -}
29   -
30   -- (void)dealloc {
31   - NSLog(@"CNLiveQrCodeNavigationBar -- dealloc");
32   -}
33   -
34   -- (void)createSubViews {
35   - [self addSubview:self.navView];
36   - [self addSubview:self.left];
37   - [self addSubview:self.title];
38   - [self addSubview:self.right];
39   -}
40   -
41   -/*
42   - // Only override drawRect: if you perform custom drawing.
43   - // An empty implementation adversely affects performance during animation.
44   - - (void)drawRect:(CGRect)rect {
45   - // Drawing code
46   - }
47   - */
48   -
49   -#pragma mark - 懒加载
50   -- (UIView *)navView {
51   - if (!_navView) {
52   - _navView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, NavigationContentTop)];
53   - _navView.backgroundColor = [UIColor clearColor];
54   - }
55   - return _navView;
56   -}
57   -
58   -- (UIButton *)left {
59   - if (!_left) {
60   - _left= [UIButton buttonWithType:UIButtonTypeCustom];
61   - _left.adjustsImageWhenHighlighted = NO;
62   - _left.frame = CGRectMake(margin, StatusBarHeight, NavigationBarHeight, NavigationBarHeight);
63   - UIImage *image = [self getImageWithImageName:@"mine_back_white_b" bundleName:@"CNLiveQrCodeModule" targetClass:[CNLiveQrCodeNavigationBar class]];
64   - [_left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
65   - [_left setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
66   - [_left addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
67   - }
68   - return _left;
69   -}
70   -
71   -- (UILabel *)title {
72   - if (!_title) {
73   - _title = [[UILabel alloc] initWithFrame:CGRectMake(margin+NavigationBarHeight, StatusBarHeight, SCREEN_WIDTH-2*(margin+NavigationBarHeight), NavigationBarHeight)];
74   - [_title setFont:[UIFont systemFontOfSize:18]];
75   - _title.textColor = [UIColor whiteColor];
76   - _title.textAlignment = NSTextAlignmentCenter;
77   - }
78   - return _title;
79   -}
80   -
81   -- (UIButton *)right {
82   - if (!_right) {
83   - _right = [UIButton buttonWithType:UIButtonTypeCustom];
84   - _right.frame = CGRectMake(SCREEN_WIDTH-50-margin, StatusBarHeight, 50, NavigationBarHeight);
85   - [_right setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
86   - _right.adjustsImageWhenHighlighted = NO;
87   - _right.titleLabel.font = [UIFont systemFontOfSize:15];
88   - [_right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
89   - [_right addTarget:self action:@selector(rightDidClicked:) forControlEvents:UIControlEventTouchUpInside];
90   - }
91   - return _right;
92   -}
93   -
94   -#pragma mark - 响应方法
95   -- (void)goBack{
96   - if (self.delegate && [self.delegate respondsToSelector:@selector(navigationBar:actionEvents:)]) {
97   - [self.delegate navigationBar:self actionEvents:@"1"];
98   - }
99   -}
100   -- (void)rightDidClicked:(UIButton *)btn{
101   - if (self.delegate && [self.delegate respondsToSelector:@selector(navigationBar:actionEvents:)]) {
102   - [self.delegate navigationBar:self actionEvents:@"2"];
103   - }
104   -}
105   -
106   -@end
Example/CNLiveQrCodeModule.xcodeproj/project.pbxproj
... ... @@ -375,6 +375,7 @@
375 375 "${BUILT_PRODUCTS_DIR}/CNLiveCategory/CNLiveCategory.framework",
376 376 "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework",
377 377 "${BUILT_PRODUCTS_DIR}/CNLiveCommonClass/CNLiveCommonClass.framework",
  378 + "${BUILT_PRODUCTS_DIR}/CNLiveCustomControl/CNLiveCustomControl.framework",
378 379 "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework",
379 380 "${BUILT_PRODUCTS_DIR}/CNLiveManager/CNLiveManager.framework",
380 381 "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework",
... ... @@ -397,6 +398,7 @@
397 398 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCategory.framework",
398 399 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework",
399 400 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonClass.framework",
  401 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCustomControl.framework",
400 402 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework",
401 403 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveManager.framework",
402 404 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework",
... ...
Example/CNLiveQrCodeModule/CNLIVEAppDelegate.m
... ... @@ -63,7 +63,7 @@
63 63 }];
64 64 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
65 65  
66   - CNLiveMyQrCodeController *vc = [[CNLiveMyQrCodeController alloc] init];
  66 + CNLiveGroupQrCodeController *vc = [[CNLiveGroupQrCodeController alloc] init];
67 67 // vc.ID = @"http://www.baidu.com";
68 68 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
69 69  
... ...