Commit 551a21e27cb78a443bc48405e2703ad0a9a59e54
1 parent
1a79531e
no message
Showing
28 changed files
with
40 additions
and
537 deletions
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/code_refresh.imageset/Contents.json deleted
100644 → 0
| 1 | -{ | ||
| 2 | - "images" : [ | ||
| 3 | - { | ||
| 4 | - "idiom" : "universal", | ||
| 5 | - "scale" : "1x" | ||
| 6 | - }, | ||
| 7 | - { | ||
| 8 | - "idiom" : "universal", | ||
| 9 | - "filename" : "code_refresh@2x.png", | ||
| 10 | - "scale" : "2x" | ||
| 11 | - }, | ||
| 12 | - { | ||
| 13 | - "idiom" : "universal", | ||
| 14 | - "filename" : "code_refresh@3x.png", | ||
| 15 | - "scale" : "3x" | ||
| 16 | - } | ||
| 17 | - ], | ||
| 18 | - "info" : { | ||
| 19 | - "version" : 1, | ||
| 20 | - "author" : "xcode" | ||
| 21 | - } | ||
| 22 | -} | ||
| 23 | \ No newline at end of file | 0 | \ No newline at end of file |
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/code_refresh.imageset/code_refresh@2x.png deleted
100644 → 0
1.46 KB
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/code_refresh.imageset/code_refresh@3x.png deleted
100644 → 0
2.57 KB
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_all_front.imageset/Contents.json deleted
100644 → 0
| 1 | -{ | ||
| 2 | - "images" : [ | ||
| 3 | - { | ||
| 4 | - "idiom" : "universal", | ||
| 5 | - "scale" : "1x" | ||
| 6 | - }, | ||
| 7 | - { | ||
| 8 | - "idiom" : "universal", | ||
| 9 | - "filename" : "mine_all_front@2x.png", | ||
| 10 | - "scale" : "2x" | ||
| 11 | - }, | ||
| 12 | - { | ||
| 13 | - "idiom" : "universal", | ||
| 14 | - "filename" : "mine_all_front@3x.png", | ||
| 15 | - "scale" : "3x" | ||
| 16 | - } | ||
| 17 | - ], | ||
| 18 | - "info" : { | ||
| 19 | - "version" : 1, | ||
| 20 | - "author" : "xcode" | ||
| 21 | - } | ||
| 22 | -} | ||
| 23 | \ No newline at end of file | 0 | \ No newline at end of file |
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_all_front.imageset/mine_all_front@2x.png deleted
100644 → 0
266 Bytes
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_all_front.imageset/mine_all_front@3x.png deleted
100644 → 0
615 Bytes
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_bg.imageset/Contents.json deleted
100644 → 0
| 1 | -{ | ||
| 2 | - "images" : [ | ||
| 3 | - { | ||
| 4 | - "idiom" : "universal", | ||
| 5 | - "scale" : "1x" | ||
| 6 | - }, | ||
| 7 | - { | ||
| 8 | - "idiom" : "universal", | ||
| 9 | - "filename" : "mine_bg@2x.png", | ||
| 10 | - "scale" : "2x" | ||
| 11 | - }, | ||
| 12 | - { | ||
| 13 | - "idiom" : "universal", | ||
| 14 | - "filename" : "mine_bg@3x.png", | ||
| 15 | - "scale" : "3x" | ||
| 16 | - } | ||
| 17 | - ], | ||
| 18 | - "info" : { | ||
| 19 | - "version" : 1, | ||
| 20 | - "author" : "xcode" | ||
| 21 | - } | ||
| 22 | -} | ||
| 23 | \ No newline at end of file | 0 | \ No newline at end of file |
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_bg.imageset/mine_bg@2x.png deleted
100644 → 0
25.9 KB
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_bg.imageset/mine_bg@3x.png deleted
100644 → 0
50.7 KB
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_code.imageset/Contents.json deleted
100644 → 0
| 1 | -{ | ||
| 2 | - "images" : [ | ||
| 3 | - { | ||
| 4 | - "idiom" : "universal", | ||
| 5 | - "scale" : "1x" | ||
| 6 | - }, | ||
| 7 | - { | ||
| 8 | - "idiom" : "universal", | ||
| 9 | - "filename" : "mine_code@2x.png", | ||
| 10 | - "scale" : "2x" | ||
| 11 | - }, | ||
| 12 | - { | ||
| 13 | - "idiom" : "universal", | ||
| 14 | - "filename" : "mine_code@3x.png", | ||
| 15 | - "scale" : "3x" | ||
| 16 | - } | ||
| 17 | - ], | ||
| 18 | - "info" : { | ||
| 19 | - "version" : 1, | ||
| 20 | - "author" : "xcode" | ||
| 21 | - } | ||
| 22 | -} | ||
| 23 | \ No newline at end of file | 0 | \ No newline at end of file |
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_code.imageset/mine_code@2x.png deleted
100644 → 0
1.06 KB
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_code.imageset/mine_code@3x.png deleted
100644 → 0
2.03 KB
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_info_qrcode.imageset/Contents.json deleted
100644 → 0
| 1 | -{ | ||
| 2 | - "images" : [ | ||
| 3 | - { | ||
| 4 | - "idiom" : "universal", | ||
| 5 | - "scale" : "1x" | ||
| 6 | - }, | ||
| 7 | - { | ||
| 8 | - "idiom" : "universal", | ||
| 9 | - "filename" : "mine_info_qrcode@2x.png", | ||
| 10 | - "scale" : "2x" | ||
| 11 | - }, | ||
| 12 | - { | ||
| 13 | - "idiom" : "universal", | ||
| 14 | - "filename" : "mine_info_qrcode@3x.png", | ||
| 15 | - "scale" : "3x" | ||
| 16 | - } | ||
| 17 | - ], | ||
| 18 | - "info" : { | ||
| 19 | - "version" : 1, | ||
| 20 | - "author" : "xcode" | ||
| 21 | - } | ||
| 22 | -} | ||
| 23 | \ No newline at end of file | 0 | \ No newline at end of file |
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_info_qrcode.imageset/mine_info_qrcode@2x.png deleted
100644 → 0
1.64 KB
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_info_qrcode.imageset/mine_info_qrcode@3x.png deleted
100644 → 0
1.73 KB
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_info_set.imageset/mine_info_set@2x.png
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_info_set.imageset/mine_info_set@3x.png
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_location.imageset/Contents.json deleted
100644 → 0
| 1 | -{ | ||
| 2 | - "images" : [ | ||
| 3 | - { | ||
| 4 | - "idiom" : "universal", | ||
| 5 | - "scale" : "1x" | ||
| 6 | - }, | ||
| 7 | - { | ||
| 8 | - "idiom" : "universal", | ||
| 9 | - "filename" : "mine_location@2x.png", | ||
| 10 | - "scale" : "2x" | ||
| 11 | - }, | ||
| 12 | - { | ||
| 13 | - "idiom" : "universal", | ||
| 14 | - "filename" : "mine_location@3x.png", | ||
| 15 | - "scale" : "3x" | ||
| 16 | - } | ||
| 17 | - ], | ||
| 18 | - "info" : { | ||
| 19 | - "version" : 1, | ||
| 20 | - "author" : "xcode" | ||
| 21 | - } | ||
| 22 | -} | ||
| 23 | \ No newline at end of file | 0 | \ No newline at end of file |
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_location.imageset/mine_location@2x.png deleted
100644 → 0
767 Bytes
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_location.imageset/mine_location@3x.png deleted
100644 → 0
1.47 KB
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_observer.imageset/Contents.json deleted
100644 → 0
| 1 | -{ | ||
| 2 | - "images" : [ | ||
| 3 | - { | ||
| 4 | - "idiom" : "universal", | ||
| 5 | - "scale" : "1x" | ||
| 6 | - }, | ||
| 7 | - { | ||
| 8 | - "idiom" : "universal", | ||
| 9 | - "filename" : "mine_observer@2x.png", | ||
| 10 | - "scale" : "2x" | ||
| 11 | - }, | ||
| 12 | - { | ||
| 13 | - "idiom" : "universal", | ||
| 14 | - "scale" : "3x" | ||
| 15 | - } | ||
| 16 | - ], | ||
| 17 | - "info" : { | ||
| 18 | - "version" : 1, | ||
| 19 | - "author" : "xcode" | ||
| 20 | - } | ||
| 21 | -} | ||
| 22 | \ No newline at end of file | 0 | \ No newline at end of file |
CNLiveSettingModule/Assets/CNLiveSettingModule.xcassets/mine_observer.imageset/mine_observer@2x.png deleted
100644 → 0
68.8 KB
CNLiveSettingModule/Classes/Controller/CNLiveSettingController.m
| @@ -196,21 +196,36 @@ | @@ -196,21 +196,36 @@ | ||
| 196 | 196 | ||
| 197 | } | 197 | } |
| 198 | else if(indexPath.row == 7){ // 清除缓存 | 198 | else if(indexPath.row == 7){ // 清除缓存 |
| 199 | -// XWAlertController *alertController = [XWAlertController alertControllerWithTitle:@"确定清除本地缓存吗?" message:@"" preferredStyle:XWAlertControllerStyleAlert]; | ||
| 200 | -// alertController.needDialogBlur = NO; | ||
| 201 | -// | ||
| 202 | -// __weak typeof(self) weakSelf = self; | ||
| 203 | -// XWAlertAction *action1 = [XWAlertAction actionWithTitle:@"取消" style:XWAlertActionStyleCancel handler:^(XWAlertAction * _Nonnull action) { | ||
| 204 | -// }]; | ||
| 205 | -// XWAlertAction *action2 = [XWAlertAction actionWithTitle:@"确定" style:XWAlertActionStyleDefault handler:^(XWAlertAction * _Nonnull action) { | ||
| 206 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | ||
| 207 | -// if(!strongSelf) return ; | ||
| 208 | -// [strongSelf cleanLocalCache]; | ||
| 209 | -// }]; | ||
| 210 | -// action2.titleColor = HexColor(0x23d41e); | ||
| 211 | -// [alertController addAction:action1]; | ||
| 212 | -// [alertController addAction:action2]; | ||
| 213 | -// [self presentViewController:alertController animated:YES completion:nil]; | 199 | + __weak typeof(self) weakSelf = self; |
| 200 | + QMUIAlertAction *sure = [QMUIAlertAction actionWithTitle:@"确定" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | ||
| 201 | + __strong typeof(weakSelf) strongSelf = weakSelf; | ||
| 202 | + if(!strongSelf) return ; | ||
| 203 | + [strongSelf cleanLocalCache]; | ||
| 204 | + | ||
| 205 | + }]; | ||
| 206 | + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | ||
| 207 | + __strong typeof(weakSelf) strongSelf = weakSelf; | ||
| 208 | + if(!strongSelf) return ; | ||
| 209 | + self.navigationBar.right.userInteractionEnabled = YES; | ||
| 210 | + | ||
| 211 | + }]; | ||
| 212 | + | ||
| 213 | + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"确定清除本地缓存吗?" message:@"" preferredStyle:QMUIAlertControllerStyleAlert]; | ||
| 214 | + [alertController addAction:sure]; | ||
| 215 | + [alertController addAction:cancel]; | ||
| 216 | + | ||
| 217 | + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | ||
| 218 | + | ||
| 219 | + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0]; | ||
| 220 | + | ||
| 221 | + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | ||
| 222 | + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]; | ||
| 223 | + | ||
| 224 | + sure.buttonAttributes = titleAttributs; | ||
| 225 | + cancel.buttonAttributes = cancelAttributs; | ||
| 226 | + | ||
| 227 | + [alertController showWithAnimated:YES]; | ||
| 228 | + | ||
| 214 | }else{ | 229 | }else{ |
| 215 | 230 | ||
| 216 | } | 231 | } |
| @@ -220,7 +235,6 @@ | @@ -220,7 +235,6 @@ | ||
| 220 | - (NSMutableArray *)data { | 235 | - (NSMutableArray *)data { |
| 221 | if (!_data) { | 236 | if (!_data) { |
| 222 | _data = [NSMutableArray array]; | 237 | _data = [NSMutableArray array]; |
| 223 | - | ||
| 224 | } | 238 | } |
| 225 | return _data; | 239 | return _data; |
| 226 | } | 240 | } |
| @@ -247,7 +261,6 @@ | @@ -247,7 +261,6 @@ | ||
| 247 | _tableView.estimatedSectionHeaderHeight = 0; | 261 | _tableView.estimatedSectionHeaderHeight = 0; |
| 248 | _tableView.estimatedSectionFooterHeight = 0; | 262 | _tableView.estimatedSectionFooterHeight = 0; |
| 249 | [_tableView registerClass:[CNLiveSettingCell class] forCellReuseIdentifier:kCNLiveSettingCell]; | 263 | [_tableView registerClass:[CNLiveSettingCell class] forCellReuseIdentifier:kCNLiveSettingCell]; |
| 250 | - | ||
| 251 | } | 264 | } |
| 252 | return _tableView; | 265 | return _tableView; |
| 253 | } | 266 | } |
| @@ -264,11 +277,11 @@ | @@ -264,11 +277,11 @@ | ||
| 264 | } | 277 | } |
| 265 | return _logout; | 278 | return _logout; |
| 266 | } | 279 | } |
| 280 | + | ||
| 267 | #pragma mark - 响应方法 | 281 | #pragma mark - 响应方法 |
| 268 | - (void)goBack { | 282 | - (void)goBack { |
| 269 | if (self.presentingViewController != nil) { | 283 | if (self.presentingViewController != nil) { |
| 270 | [self dismissViewControllerAnimated:YES completion:nil]; | 284 | [self dismissViewControllerAnimated:YES completion:nil]; |
| 271 | - | ||
| 272 | } | 285 | } |
| 273 | else { | 286 | else { |
| 274 | [self.navigationController popViewControllerAnimated:YES]; | 287 | [self.navigationController popViewControllerAnimated:YES]; |
| @@ -277,9 +290,10 @@ | @@ -277,9 +290,10 @@ | ||
| 277 | - (void)logoutDidClicked:(UIButton *)btn{ | 290 | - (void)logoutDidClicked:(UIButton *)btn{ |
| 278 | [UIApplication sharedApplication].delegate.window.rootViewController = nil; | 291 | [UIApplication sharedApplication].delegate.window.rootViewController = nil; |
| 279 | [self cleanLocalCache]; | 292 | [self cleanLocalCache]; |
| 280 | -// id<XWLoginServiceProtocol> login = [[BeeHive shareInstance] createService:@protocol(XWLoginServiceProtocol)]; | ||
| 281 | -// XWBaseNavigationController *nav = [[XWBaseNavigationController alloc] initWithRootViewController:[login getLoginViewController]]; | ||
| 282 | -// [UIApplication sharedApplication].delegate.window.rootViewController = nav; | 293 | + id<CNLiveLoginServiceProtocol> login = [[BeeHive shareInstance] createService:@protocol(CNLiveLoginServiceProtocol)]; |
| 294 | + UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[login getLoginViewController]]; | ||
| 295 | + [UIApplication sharedApplication].delegate.window.rootViewController = nav; | ||
| 296 | + | ||
| 283 | } | 297 | } |
| 284 | 298 | ||
| 285 | #pragma mark - 私有方法 | 299 | #pragma mark - 私有方法 |
CNLiveSettingModule/Classes/Module/CNLiveSettingService.m
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | 17 | ||
| 18 | @implementation CNLiveSettingService | 18 | @implementation CNLiveSettingService |
| 19 | 19 | ||
| 20 | -// 我的 | 20 | +// 设置 |
| 21 | - (UIViewController *)getMineViewController { | 21 | - (UIViewController *)getMineViewController { |
| 22 | return [CNLiveSettingController new]; | 22 | return [CNLiveSettingController new]; |
| 23 | } | 23 | } |
CNLiveSettingModule/Classes/View/CNLiveSettingCell.m
| @@ -53,14 +53,14 @@ static const NSInteger margin = 12; | @@ -53,14 +53,14 @@ static const NSInteger margin = 12; | ||
| 53 | }]; | 53 | }]; |
| 54 | 54 | ||
| 55 | [_title mas_updateConstraints:^(MASConstraintMaker *make) { | 55 | [_title mas_updateConstraints:^(MASConstraintMaker *make) { |
| 56 | - make.left.equalTo(self.line.mas_left).with.offset(1.5*margin); | 56 | + make.left.equalTo(self.line.mas_left).with.offset(margin); |
| 57 | make.top.equalTo(self.line.mas_bottom).with.offset(0); | 57 | make.top.equalTo(self.line.mas_bottom).with.offset(0); |
| 58 | make.height.offset(self.model.height-self.model.lineHeight); | 58 | make.height.offset(self.model.height-self.model.lineHeight); |
| 59 | 59 | ||
| 60 | }]; | 60 | }]; |
| 61 | 61 | ||
| 62 | [_front mas_updateConstraints:^(MASConstraintMaker *make) { | 62 | [_front mas_updateConstraints:^(MASConstraintMaker *make) { |
| 63 | - make.right.equalTo(self.line.mas_right).with.offset(-1.5*margin); | 63 | + make.right.equalTo(self.line.mas_right).with.offset(-margin); |
| 64 | make.top.equalTo(self.title.mas_top).with.offset(0); | 64 | make.top.equalTo(self.title.mas_top).with.offset(0); |
| 65 | make.width.with.offset(margin); | 65 | make.width.with.offset(margin); |
| 66 | make.height.equalTo(self.title.mas_height); | 66 | make.height.equalTo(self.title.mas_height); |
| @@ -90,7 +90,7 @@ static const NSInteger margin = 12; | @@ -90,7 +90,7 @@ static const NSInteger margin = 12; | ||
| 90 | [_switchOn mas_updateConstraints:^(MASConstraintMaker *make) { | 90 | [_switchOn mas_updateConstraints:^(MASConstraintMaker *make) { |
| 91 | // UISwithch的大小无效.默认大小 51.0f 31.0f) | 91 | // UISwithch的大小无效.默认大小 51.0f 31.0f) |
| 92 | make.top.equalTo(self.line.mas_bottom).with.offset(margin); | 92 | make.top.equalTo(self.line.mas_bottom).with.offset(margin); |
| 93 | - make.right.equalTo(self.line.mas_right).with.offset(-1.5*margin); | 93 | + make.right.equalTo(self.line.mas_right).with.offset(-margin); |
| 94 | 94 | ||
| 95 | }]; | 95 | }]; |
| 96 | 96 |
CNLiveSettingModule/Classes/View/CNLiveSettingHeaderView.h deleted
100644 → 0
| 1 | -// | ||
| 2 | -// CNLiveSettingHeaderView.h | ||
| 3 | -// CNLiveSettingModule | ||
| 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 | -typedef NS_ENUM(NSInteger, CNLiveMineHeaderViewType) { | ||
| 13 | - CNLiveMineHeaderViewTypeUerInfo = 0, | ||
| 14 | - CNLiveMineHeaderViewTypeCode = 1, | ||
| 15 | - CNLiveMineHeaderViewTypeWintess = 2, | ||
| 16 | - CNLiveMineHeaderViewTypeSign = 3 | ||
| 17 | - | ||
| 18 | -}; | ||
| 19 | -@class CNLiveSettingHeaderView; | ||
| 20 | - | ||
| 21 | -@protocol CNLiveSettingHeaderViewDelegate <NSObject> | ||
| 22 | -@optional | ||
| 23 | -- (void)headerView:(CNLiveSettingHeaderView *)headerView pushToController:(CNLiveMineHeaderViewType)type; | ||
| 24 | - | ||
| 25 | -@end | ||
| 26 | -@interface CNLiveSettingHeaderView : UIView | ||
| 27 | -@property (nonatomic, weak) id<CNLiveSettingHeaderViewDelegate> delegate; | ||
| 28 | -- (void)layoutSubviews; | ||
| 29 | - | ||
| 30 | -@end | ||
| 31 | - | ||
| 32 | -NS_ASSUME_NONNULL_END |
CNLiveSettingModule/Classes/View/CNLiveSettingHeaderView.m deleted
100644 → 0
| 1 | -// | ||
| 2 | -// CNLiveSettingHeaderView.m | ||
| 3 | -// CNLiveSettingModule | ||
| 4 | -// | ||
| 5 | -// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | -// Copyright © 2019 153993236@qq.com. All rights reserved. | ||
| 7 | -// | ||
| 8 | - | ||
| 9 | -#import "CNLiveSettingHeaderView.h" | ||
| 10 | -#import <Masonry/Masonry.h> | ||
| 11 | -#import <SDWebImage/SDWebImage.h> | ||
| 12 | -#import "QMUIKit.h" | ||
| 13 | - | ||
| 14 | -@interface CNLiveSettingHeaderView () | ||
| 15 | -@property (nonatomic, strong) UIImageView *bgView; | ||
| 16 | -@property (nonatomic, strong) UIButton *witness; | ||
| 17 | - | ||
| 18 | -@property (nonatomic, strong) UIImageView *header; | ||
| 19 | -@property (nonatomic, strong) UILabel *name; | ||
| 20 | -@property (nonatomic, strong) UILabel *certification; | ||
| 21 | -@property (nonatomic, strong) UILabel *address; | ||
| 22 | -@property (nonatomic, strong) UIButton *sign; | ||
| 23 | - | ||
| 24 | -@end | ||
| 25 | - | ||
| 26 | -@implementation CNLiveSettingHeaderView | ||
| 27 | -static const NSInteger margin = 20; | ||
| 28 | - | ||
| 29 | -- (instancetype)initWithFrame:(CGRect)frame{ | ||
| 30 | - self = [super initWithFrame:frame]; | ||
| 31 | - if(self){ | ||
| 32 | - self.userInteractionEnabled = YES; | ||
| 33 | - self.backgroundColor = [UIColor colorWithRed:244.0/255.0 green:244.0/255.0 blue:244.0/255.0 alpha:1.0]; | ||
| 34 | -// [XWUserInfoNotification addUserInfoUpdateObserver:self selector:@selector(userInfoUpdateNotification:)]; | ||
| 35 | - [self createSubViews]; | ||
| 36 | - } | ||
| 37 | - return self; | ||
| 38 | -} | ||
| 39 | -// 实现方法 | ||
| 40 | -- (void)userInfoUpdateNotification:(NSNotification *)noti{ | ||
| 41 | - //使用userInfo处理消息 | ||
| 42 | -// NSDictionary *dic = [noti userInfo]; | ||
| 43 | -// XWUserInfoDataType type = [[dic objectForKey:@"type"] integerValue]; | ||
| 44 | -// if(type == XWUserInfoDataTypeHead){ | ||
| 45 | -// UIImage *info = [dic objectForKey:@"info"]; | ||
| 46 | -// _header.image = info; | ||
| 47 | -// | ||
| 48 | -// }else if(type == XWUserInfoDataTypeNickname){ | ||
| 49 | -// NSString *info = [dic objectForKey:@"info"]; | ||
| 50 | -// _name.attributedText = [self createAttributedImageName:@"mine_code" string:info isFront:NO]; | ||
| 51 | -// | ||
| 52 | -// }else if(type == XWUserInfoDataTypeAddress){ | ||
| 53 | -// NSString *info = [dic objectForKey:@"info"]; | ||
| 54 | -// _address.attributedText = [self createAttributedImageName:@"mine_location" string:info isFront:YES]; | ||
| 55 | -// | ||
| 56 | -// } | ||
| 57 | -} | ||
| 58 | - | ||
| 59 | -- (void)dealloc { | ||
| 60 | - NSLog(@"CNLiveMineHeaderView -- dealloc"); | ||
| 61 | -// [XWUserInfoNotification removeObserver:self]; | ||
| 62 | - | ||
| 63 | -} | ||
| 64 | - | ||
| 65 | -- (void)createSubViews { | ||
| 66 | - [self addSubview:self.bgView]; | ||
| 67 | - [self addSubview:self.witness]; | ||
| 68 | - | ||
| 69 | - [self addSubview:self.header]; | ||
| 70 | - [self addSubview:self.name]; | ||
| 71 | - [self addSubview:self.certification]; | ||
| 72 | - [self addSubview:self.address]; | ||
| 73 | - [self addSubview:self.sign]; | ||
| 74 | - | ||
| 75 | -} | ||
| 76 | - | ||
| 77 | -- (void)layoutSubviews{ | ||
| 78 | - [super layoutSubviews]; | ||
| 79 | - [_witness mas_remakeConstraints:^(MASConstraintMaker *make) { | ||
| 80 | - make.left.equalTo(self.mas_left).with.offset(1.5*margin); | ||
| 81 | - make.right.equalTo(self.mas_right).with.offset(-1.5*margin); | ||
| 82 | - make.width.height.offset(60); | ||
| 83 | - make.bottom.equalTo(self.mas_bottom).with.offset(-0.5*margin); | ||
| 84 | - | ||
| 85 | - }]; | ||
| 86 | - | ||
| 87 | - [_bgView mas_remakeConstraints:^(MASConstraintMaker *make) { | ||
| 88 | - make.left.equalTo(self.mas_left).with.offset(0); | ||
| 89 | - make.right.equalTo(self.mas_right).with.offset(-0); | ||
| 90 | - make.top.equalTo(self.mas_top).with.offset(0); | ||
| 91 | - make.bottom.equalTo(self.witness.mas_centerY).with.offset(0.5*margin); | ||
| 92 | - | ||
| 93 | - }]; | ||
| 94 | - | ||
| 95 | - [_header mas_remakeConstraints:^(MASConstraintMaker *make) { | ||
| 96 | - make.left.equalTo(self.mas_left).with.offset(margin); | ||
| 97 | - make.centerY.equalTo(self.bgView.mas_centerY).with.offset(0); | ||
| 98 | - make.width.height.offset(60); | ||
| 99 | - | ||
| 100 | - }]; | ||
| 101 | - | ||
| 102 | - [_certification mas_remakeConstraints:^(MASConstraintMaker *make) { | ||
| 103 | - make.centerY.equalTo(self.header.mas_centerY); | ||
| 104 | - make.left.equalTo(self.header.mas_right).with.offset(margin/2.0); | ||
| 105 | - make.height.offset(35); | ||
| 106 | - | ||
| 107 | - }]; | ||
| 108 | - | ||
| 109 | - [_name mas_remakeConstraints:^(MASConstraintMaker *make) { | ||
| 110 | - make.bottom.equalTo(self.certification.mas_top); | ||
| 111 | - make.left.equalTo(self.certification.mas_left); | ||
| 112 | - make.right.equalTo(self.bgView.mas_right).with.offset(-margin); | ||
| 113 | - make.height.equalTo(self.certification.mas_height); | ||
| 114 | - | ||
| 115 | - }]; | ||
| 116 | - | ||
| 117 | - [_address mas_remakeConstraints:^(MASConstraintMaker *make) { | ||
| 118 | - make.top.equalTo(self.certification.mas_bottom); | ||
| 119 | - make.left.equalTo(self.name.mas_left); | ||
| 120 | - make.right.equalTo(self.name.mas_right); | ||
| 121 | - make.height.equalTo(self.name.mas_height); | ||
| 122 | - | ||
| 123 | - }]; | ||
| 124 | - | ||
| 125 | - [_sign mas_remakeConstraints:^(MASConstraintMaker *make) { | ||
| 126 | - make.right.equalTo(self.mas_right).with.offset(0); | ||
| 127 | - make.centerY.equalTo(self.header.mas_centerY).with.offset(0); | ||
| 128 | - make.width.mas_equalTo(105); | ||
| 129 | - make.height.mas_equalTo(32); | ||
| 130 | - | ||
| 131 | - }]; | ||
| 132 | -} | ||
| 133 | -/* | ||
| 134 | - // Only override drawRect: if you perform custom drawing. | ||
| 135 | - // An empty implementation adversely affects performance during animation. | ||
| 136 | - - (void)drawRect:(CGRect)rect { | ||
| 137 | - // Drawing code | ||
| 138 | - } | ||
| 139 | - */ | ||
| 140 | -#pragma mark - Private Methods | ||
| 141 | -- (NSMutableAttributedString *)createAttributedImageName:(NSString *)imageName string:(NSString *)string isFront:(BOOL)isFront{ | ||
| 142 | - if(isFront){ | ||
| 143 | - string = [NSString stringWithFormat:@" %@",string]; | ||
| 144 | - } | ||
| 145 | - // 1.创建一个富文本 | ||
| 146 | - NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:string]; | ||
| 147 | - // 修改富文本中的不同文字的样式 | ||
| 148 | -// [attri addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, string.length)]; | ||
| 149 | -// [attri addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, string.length)]; | ||
| 150 | - // 2.添加表情图片 | ||
| 151 | - NSTextAttachment *attch = [[NSTextAttachment alloc] init]; | ||
| 152 | - // 表情图片 | ||
| 153 | - UIImage *xw_image = [self xw_getImageName:imageName bundleName:@"CNLiveSettingModule" targetClass:[CNLiveSettingHeaderView class]]; | ||
| 154 | - attch.image = xw_image; | ||
| 155 | - if(isFront){ | ||
| 156 | - // 设置图片大小 | ||
| 157 | - attch.bounds = CGRectMake(0, -1.5, 10, 12); | ||
| 158 | - // 创建带有图片的富文本 | ||
| 159 | - NSAttributedString *str = [NSAttributedString attributedStringWithAttachment:attch]; | ||
| 160 | - [attri insertAttributedString:str atIndex:0];// 插入某个位置 | ||
| 161 | - }else{ | ||
| 162 | - // 设置图片大小 | ||
| 163 | - attch.bounds = CGRectMake(10, -2, 15, 15); | ||
| 164 | - // 创建带有图片的富文本 | ||
| 165 | - NSAttributedString *str = [NSAttributedString attributedStringWithAttachment:attch]; | ||
| 166 | - [attri insertAttributedString:str atIndex:string.length];// 插入某个位置 | ||
| 167 | - | ||
| 168 | - } | ||
| 169 | - return attri; | ||
| 170 | - | ||
| 171 | -} | ||
| 172 | -- (NSMutableAttributedString *)createAttributedImages:(NSArray *)images { | ||
| 173 | - // 1.创建一个富文本 | ||
| 174 | - NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:@""]; | ||
| 175 | - for(NSString *image in images){ | ||
| 176 | - // 2.添加表情图片 | ||
| 177 | - NSTextAttachment *attch = [[NSTextAttachment alloc] init]; | ||
| 178 | - // 表情图片 | ||
| 179 | - UIImage *xw_image = [self xw_getImageName:image bundleName:@"CNLiveSettingModule" targetClass:[CNLiveSettingHeaderView class]]; | ||
| 180 | - attch.image = xw_image; | ||
| 181 | - // 创建带有图片的富文本 | ||
| 182 | - NSAttributedString *str = [NSAttributedString attributedStringWithAttachment:attch]; | ||
| 183 | - NSAttributedString *space = [[NSAttributedString alloc]initWithString:@" "]; | ||
| 184 | - | ||
| 185 | - [attri insertAttributedString:space atIndex:0]; | ||
| 186 | - [attri insertAttributedString:str atIndex:0];// 插入某个位置 | ||
| 187 | - | ||
| 188 | - } | ||
| 189 | - return attri; | ||
| 190 | - | ||
| 191 | -} | ||
| 192 | - | ||
| 193 | -#pragma mark - 懒加载 | ||
| 194 | -- (UIButton *)witness { | ||
| 195 | - if (!_witness) { | ||
| 196 | - _witness = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 197 | - UIImage *xw_image = [self xw_getImageName:@"mine_observer" bundleName:@"CNLiveSettingModule" targetClass:[CNLiveSettingHeaderView class]]; | ||
| 198 | - _witness.imageView.contentMode = UIViewContentModeScaleAspectFit; | ||
| 199 | - [_witness setImage:xw_image forState:UIControlStateNormal]; | ||
| 200 | - _witness.adjustsImageWhenHighlighted = NO; | ||
| 201 | - [_witness addTarget:self action:@selector(witnessDidClicked:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 202 | - } | ||
| 203 | - return _witness; | ||
| 204 | -} | ||
| 205 | -- (UIImageView *)bgView { | ||
| 206 | - if (!_bgView) { | ||
| 207 | - _bgView = [[UIImageView alloc] init]; | ||
| 208 | - _bgView.userInteractionEnabled = YES; | ||
| 209 | - UIImage *xw_image = [self xw_getImageName:@"mine_bg" bundleName:@"CNLiveSettingModule" targetClass:[CNLiveSettingHeaderView class]]; | ||
| 210 | - _bgView.image = xw_image; | ||
| 211 | - } | ||
| 212 | - return _bgView; | ||
| 213 | -} | ||
| 214 | -- (UIImageView *)header { | ||
| 215 | - if (!_header) { | ||
| 216 | - _header = [[UIImageView alloc] init]; | ||
| 217 | - _header.userInteractionEnabled = YES; | ||
| 218 | - _header.layer.masksToBounds = YES; | ||
| 219 | - _header.layer.cornerRadius = 30; | ||
| 220 | - UIImage *xw_image = [self xw_getImageName:@"default_avatar_y" bundleName:@"CNLiveSettingModule" targetClass:[CNLiveSettingHeaderView class]]; | ||
| 221 | - [_header sd_setImageWithURL:[NSURL URLWithString:@"头像"] placeholderImage:xw_image]; | ||
| 222 | - UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(headerTapDidClicked:)]; | ||
| 223 | - [_header addGestureRecognizer:tap]; | ||
| 224 | - } | ||
| 225 | - return _header; | ||
| 226 | -} | ||
| 227 | - | ||
| 228 | -- (UILabel *)name { | ||
| 229 | - if (!_name) { | ||
| 230 | - _name = [[UILabel alloc] init]; | ||
| 231 | - _name.userInteractionEnabled = YES; | ||
| 232 | - _name.numberOfLines = 1; | ||
| 233 | - _name.textColor = [UIColor whiteColor]; | ||
| 234 | - _name.font = [UIFont systemFontOfSize:16]; | ||
| 235 | - _name.attributedText = [self createAttributedImageName:@"mine_code" string:@"张晓文" isFront:NO]; | ||
| 236 | - UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(nameTapDidClicked:)]; | ||
| 237 | - [_name addGestureRecognizer:tap]; | ||
| 238 | - | ||
| 239 | - } | ||
| 240 | - return _name; | ||
| 241 | -} | ||
| 242 | -- (UILabel *)certification { | ||
| 243 | - if (!_certification) { | ||
| 244 | - _certification = [[UILabel alloc] init]; | ||
| 245 | - _certification.numberOfLines = 1; | ||
| 246 | - _certification.textColor = [UIColor whiteColor]; | ||
| 247 | - _certification.font = [UIFont systemFontOfSize:16]; | ||
| 248 | - _certification.attributedText = [self createAttributedImages:@[@"mine_overbadge",@"mine_common", @"mine_wjj_certification"]]; | ||
| 249 | - } | ||
| 250 | - return _certification; | ||
| 251 | -} | ||
| 252 | -- (UILabel *)address { | ||
| 253 | - if (!_address) { | ||
| 254 | - _address = [[UILabel alloc] init]; | ||
| 255 | - _address.numberOfLines = 1; | ||
| 256 | - _address.textColor = [UIColor colorWithRed:140/255.0 green:140/255.0 blue:142/255.0 alpha:1.0]; | ||
| 257 | - _address.font = [UIFont systemFontOfSize:13]; | ||
| 258 | - _address.attributedText = [self createAttributedImageName:@"mine_location" string:@"北京海淀区花园桥" isFront:YES]; | ||
| 259 | - } | ||
| 260 | - return _address; | ||
| 261 | -} | ||
| 262 | -- (UIButton *)sign { | ||
| 263 | - if (!_sign) { | ||
| 264 | - _sign = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 265 | - _sign.frame = CGRectMake(0, 0, 105, 32); | ||
| 266 | - _sign.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.2]; | ||
| 267 | - [_sign setTitle:@"签到赚积分" forState:UIControlStateNormal]; | ||
| 268 | - _sign.titleLabel.font = [UIFont systemFontOfSize:13.0]; | ||
| 269 | - [_sign setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | ||
| 270 | - UIImage *xw_image = [self xw_getImageName:@"sign_in_soccer" bundleName:@"CNLiveSettingModule" targetClass:[CNLiveSettingHeaderView class]]; | ||
| 271 | - [_sign setImage:xw_image forState:UIControlStateNormal]; | ||
| 272 | - [_sign addTarget:self action:@selector(signDidClicked:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 273 | - UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_sign.layer.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(16, 16)]; | ||
| 274 | - CAShapeLayer *maskLayer = [CAShapeLayer layer]; | ||
| 275 | - maskLayer.frame = _sign.bounds; | ||
| 276 | - maskLayer.path = maskPath.CGPath; | ||
| 277 | - _sign.layer.mask = maskLayer; | ||
| 278 | - } | ||
| 279 | - return _sign; | ||
| 280 | -} | ||
| 281 | - | ||
| 282 | -#pragma mark - 响应方法 | ||
| 283 | -- (void)headerTapDidClicked:(UITapGestureRecognizer *)tap{ | ||
| 284 | - if (self.delegate && [self.delegate respondsToSelector:@selector(headerView:pushToController:)]) { | ||
| 285 | - [self.delegate headerView:self pushToController:CNLiveMineHeaderViewTypeUerInfo]; | ||
| 286 | - | ||
| 287 | - } | ||
| 288 | - | ||
| 289 | -} | ||
| 290 | -- (void)nameTapDidClicked:(UITapGestureRecognizer *)tap{ | ||
| 291 | - if (self.delegate && [self.delegate respondsToSelector:@selector(headerView:pushToController:)]) { | ||
| 292 | - [self.delegate headerView:self pushToController:CNLiveMineHeaderViewTypeCode]; | ||
| 293 | - | ||
| 294 | - } | ||
| 295 | - | ||
| 296 | -} | ||
| 297 | -- (void)signDidClicked:(UIButton *)btn{ | ||
| 298 | - if (self.delegate && [self.delegate respondsToSelector:@selector(headerView:pushToController:)]) { | ||
| 299 | - [self.delegate headerView:self pushToController:CNLiveMineHeaderViewTypeSign]; | ||
| 300 | - } | ||
| 301 | -} | ||
| 302 | - | ||
| 303 | -- (void)witnessDidClicked:(UIButton *)btn{ | ||
| 304 | - if (self.delegate && [self.delegate respondsToSelector:@selector(headerView:pushToController:)]) { | ||
| 305 | - [self.delegate headerView:self pushToController:CNLiveMineHeaderViewTypeWintess]; | ||
| 306 | - } | ||
| 307 | -} | ||
| 308 | - | ||
| 309 | -/** | ||
| 310 | - * 创建图片 | ||
| 311 | - * | ||
| 312 | - * @param imageName 图片名字 | ||
| 313 | - * @param bundleName 图片所在的bundle名字 | ||
| 314 | - * @param targetClass 类和bundle的同级目录 | ||
| 315 | - * @return 返回UIImage | ||
| 316 | - */ | ||
| 317 | -- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{ | ||
| 318 | - NSBundle *bundle = [NSBundle bundleForClass:targetClass]; | ||
| 319 | - NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"]; | ||
| 320 | - NSBundle *targetBundle = [NSBundle bundleWithURL:url]; | ||
| 321 | - UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil]; | ||
| 322 | - return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil]; | ||
| 323 | - | ||
| 324 | -} | ||
| 325 | - | ||
| 326 | -@end |
CNLiveSettingModule/Classes/View/CNLiveSettingNavigationBar.m
| @@ -27,7 +27,7 @@ static const NSInteger margin = 15; | @@ -27,7 +27,7 @@ static const NSInteger margin = 15; | ||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | - (void)dealloc { | 29 | - (void)dealloc { |
| 30 | - NSLog(@"CNLiveUserInfoNavigationBar -- dealloc"); | 30 | + NSLog(@"CNLiveSettingNavigationBar -- dealloc"); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | - (void)createSubViews { | 33 | - (void)createSubViews { |