Commit b19ee7ec2ec6a987d6e4be1197a46ebdf4ec93b9

Authored by zhangxiaowen
1 parent c2cfe8c4

no message

CNLiveMineModule/Assets/CNLiveMineModule.xcassets/mine_back_black_b.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "mine_back_black_b@2x.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "filename" : "mine_back_black_b@3x.png",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "version" : 1,
  20 + "author" : "xcode"
  21 + }
  22 +}
0 23 \ No newline at end of file
... ...
CNLiveMineModule/Assets/CNLiveMineModule.xcassets/mine_back_black_b.imageset/mine_back_black_b@2x.png 0 → 100644

1.49 KB

CNLiveMineModule/Assets/CNLiveMineModule.xcassets/mine_back_black_b.imageset/mine_back_black_b@3x.png 0 → 100644

1.79 KB

CNLiveMineModule/Classes/UserInfo/CNLiveInfoUpdateController.m
... ... @@ -11,10 +11,11 @@
11 11  
12 12 #import "CNLiveUserInfoModel.h"
13 13 #import "CNLiveUserInfoNotification.h"
  14 +#import "CNLiveUserInfoNavigationBar.h"
14 15  
15   -@interface CNLiveInfoUpdateController ()<UITextFieldDelegate,UITextViewDelegate>
  16 +@interface CNLiveInfoUpdateController ()<UITextFieldDelegate,UITextViewDelegate,CNLiveUserInfoNavigationBarDelegate>
  17 +@property (nonatomic, strong) CNLiveUserInfoNavigationBar *navigationBar;
16 18 @property (nonatomic, strong) CNLiveUserInfoModel *model;
17   -@property (nonatomic, weak) UIButton *rightBtn;
18 19 @property (nonatomic, weak) UITextField *textField;
19 20 @property (nonatomic, weak) UITextView *textView;
20 21  
... ... @@ -39,6 +40,10 @@ static const NSInteger margin = 15;
39 40 }
40 41  
41 42 #pragma mark - 生命周期
  43 +- (void)viewWillAppear:(BOOL)animated{
  44 + [super viewWillAppear:animated];
  45 + self.navigationController.navigationBarHidden = YES;
  46 +}
42 47  
43 48 - (void)viewDidLoad {
44 49 [super viewDidLoad];
... ... @@ -48,11 +53,11 @@ static const NSInteger margin = 15;
48 53 else {
49 54 self.automaticallyAdjustsScrollViewInsets = NO;
50 55 }
51   - [self createNavigationbar];
  56 + [self.view addSubview:self.navigationBar];
52 57 switch (self.model.dataType) {
53 58 case CNLiveUserInfoDataTypeNickname:
54 59 {
55   - self.title = @"设置昵称";
  60 + self.navigationBar.title.text = @"设置昵称";
56 61 [self textField_layoutSubViews];
57 62 self.textField.placeholder = @"请输入昵称";
58 63  
... ... @@ -60,7 +65,7 @@ static const NSInteger margin = 15;
60 65 break;
61 66 case CNLiveUserInfoDataTypeAddress:
62 67 {
63   - self.title = @"设置地区";
  68 + self.navigationBar.title.text = @"设置地区";
64 69 [self textField_layoutSubViews];
65 70 self.textField.placeholder = @"请输入你所在的地区";
66 71  
... ... @@ -68,7 +73,7 @@ static const NSInteger margin = 15;
68 73 break;
69 74 case CNLiveUserInfoDataTypeIntroduction:
70 75 {
71   - self.title = @"设置个性签名";
  76 + self.navigationBar.title.text = @"设置个性签名";
72 77 [self textView_layoutSubViews];
73 78 }
74 79 break;
... ... @@ -86,22 +91,7 @@ static const NSInteger margin = 15;
86 91  
87 92  
88 93 }
89   -- (void)createNavigationbar{
90   - UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
91   - rightBtn.frame = CGRectMake(0, 0, 50, 25);
92   - rightBtn.backgroundColor = [UIColor lightGrayColor];
93   - rightBtn.userInteractionEnabled = NO;
94   - rightBtn.titleLabel.font = [UIFont boldSystemFontOfSize:14];
95   - [rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
96   - [rightBtn setTitle:@"完成" forState:UIControlStateNormal];
97   - rightBtn.adjustsImageWhenHighlighted = NO;
98   - [rightBtn addTarget:self action:@selector(rightDidClicked:) forControlEvents:UIControlEventTouchUpInside];
99   - rightBtn.layer.masksToBounds = YES;
100   - rightBtn.layer.cornerRadius = 5;
101   - self.rightBtn = rightBtn;
102   - UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
103   - self.navigationItem.rightBarButtonItem = rightItem;
104   -}
  94 +
105 95 - (void)textField_layoutSubViews {
106 96 UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, 50)];
107 97 bgView.backgroundColor = [UIColor whiteColor];
... ... @@ -137,8 +127,8 @@ static const NSInteger margin = 15;
137 127  
138 128 #pragma mark - UITextFieldDelegate
139 129 - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
140   - self.rightBtn.backgroundColor = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
141   - self.rightBtn.userInteractionEnabled = YES;
  130 + self.navigationBar.right.backgroundColor = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  131 + self.navigationBar.right.userInteractionEnabled = YES;
142 132 return YES;
143 133 }
144 134 - (void)textFieldDidBeginEditing:(UITextField *)textField{
... ... @@ -153,8 +143,8 @@ static const NSInteger margin = 15;
153 143 }
154 144 #pragma mark - UITextViewDelegate
155 145 - (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
156   - self.rightBtn.backgroundColor = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
157   - self.rightBtn.userInteractionEnabled = YES;
  146 + self.navigationBar.right.backgroundColor = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  147 + self.navigationBar.right.userInteractionEnabled = YES;
158 148 return YES;
159 149 }
160 150 - (BOOL)textViewShouldEndEditing:(UITextView *)textView{
... ... @@ -179,7 +169,6 @@ static const NSInteger margin = 15;
179 169 - (void)goBack {
180 170 if (self.presentingViewController != nil) {
181 171 [self dismissViewControllerAnimated:YES completion:nil];
182   -
183 172 }
184 173 else {
185 174 [self.navigationController popViewControllerAnimated:YES];
... ... @@ -188,25 +177,6 @@ static const NSInteger margin = 15;
188 177 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
189 178 [self.view endEditing:YES];
190 179 }
191   -- (void)rightDidClicked:(UIButton *)btn{
192   - switch (self.model.dataType) {
193   - case CNLiveUserInfoDataTypeNickname://昵称
194   - case CNLiveUserInfoDataTypeAddress://地区
195   - {
196   - [self requestUpdateUserInfo:self.textField.text];
197   - }
198   - break;
199   - case CNLiveUserInfoDataTypeIntroduction://简介
200   - {
201   - [self requestUpdateUserInfo:self.textView.text];
202   - }
203   - break;
204   -
205   - default:
206   - break;
207   - }
208   -
209   -}
210 180  
211 181 #pragma mark - 私有方法
212 182 - (void)requestUpdateUserInfo:(NSString *)info{
... ... @@ -248,4 +218,46 @@ static const NSInteger margin = 15;
248 218  
249 219 }
250 220  
  221 +- (void)navigationBar:(CNLiveUserInfoNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
  222 + if ([actionEvents isEqualToString:@"1"]) {
  223 + [self goBack];
  224 + }else if ([actionEvents isEqualToString:@"2"]){
  225 + switch (self.model.dataType) {
  226 + case CNLiveUserInfoDataTypeNickname://昵称
  227 + case CNLiveUserInfoDataTypeAddress://地区
  228 + {
  229 + [self requestUpdateUserInfo:self.textField.text];
  230 + }
  231 + break;
  232 + case CNLiveUserInfoDataTypeIntroduction://简介
  233 + {
  234 + [self requestUpdateUserInfo:self.textView.text];
  235 + }
  236 + break;
  237 +
  238 + default:
  239 + break;
  240 + }
  241 + }
  242 +}
  243 +#pragma mark - 懒加载
  244 +- (CNLiveUserInfoNavigationBar *)navigationBar {
  245 + if (!_navigationBar) {
  246 + _navigationBar = [[CNLiveUserInfoNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)];
  247 + _navigationBar.delegate = self;
  248 + _navigationBar.title.text = @"个人资料";
  249 + _navigationBar.right.frame = CGRectMake(SCREEN_WIDTH-44-15, StatusBarHeight+10, 44, 24);
  250 + [_navigationBar.right setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
  251 + _navigationBar.right.backgroundColor = [UIColor lightGrayColor];
  252 + _navigationBar.right.userInteractionEnabled = NO;
  253 + _navigationBar.right.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  254 + [_navigationBar.right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  255 + [_navigationBar.right setTitle:@"完成" forState:UIControlStateNormal];
  256 + _navigationBar.right.adjustsImageWhenHighlighted = NO;
  257 + _navigationBar.right.layer.masksToBounds = YES;
  258 + _navigationBar.right.layer.cornerRadius = 5;
  259 + }
  260 + return _navigationBar;
  261 +}
  262 +
251 263 @end
... ...
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoController.m
... ... @@ -15,10 +15,12 @@
15 15 #import "CNLiveInfoUpdateController.h"
16 16 #import "CNLiveUserInfoNotification.h"
17 17 #import "CNLiveMyQrCodeController.h"
  18 +#import "CNLiveUserInfoNavigationBar.h"
18 19  
19   -@interface CNLiveUserInfoController ()<UITableViewDelegate, UITableViewDataSource, CNLiveInfoUpdateDelegate>{
  20 +@interface CNLiveUserInfoController ()<UITableViewDelegate, UITableViewDataSource, CNLiveInfoUpdateDelegate, CNLiveUserInfoNavigationBarDelegate>{
20 21 UIImage *_image;
21 22 }
  23 +@property (nonatomic, strong) CNLiveUserInfoNavigationBar *navigationBar;
22 24 @property (nonatomic, strong) UITableView *tableView;
23 25 @property (nonatomic, strong) NSMutableArray *data;
24 26  
... ... @@ -89,7 +91,7 @@
89 91 #pragma mark - 生命周期
90 92 - (void)viewWillAppear:(BOOL)animated{
91 93 [super viewWillAppear:animated];
92   - self.navigationController.navigationBarHidden = NO;
  94 + self.navigationController.navigationBarHidden = YES;
93 95 }
94 96  
95 97 - (void)viewDidLoad {
... ... @@ -112,7 +114,7 @@
112 114 }
113 115  
114 116 - (void)createSubViews {
115   - self.title = @"个人资料";
  117 + [self.view addSubview:self.navigationBar];
116 118 [self.view addSubview:self.tableView];
117 119  
118 120 }
... ... @@ -188,6 +190,11 @@
188 190 [self updateDataType:dataType info:info];
189 191 }
190 192  
  193 +- (void)navigationBar:(CNLiveUserInfoNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
  194 + if ([actionEvents isEqualToString:@"1"]) {
  195 + [self goBack];
  196 + }
  197 +}
191 198 #pragma mark - 私有方法
192 199 // 修改头像
193 200 - (void)updateHeaderActionSheetView{
... ... @@ -226,6 +233,16 @@
226 233 }
227 234  
228 235 #pragma mark - 懒加载
  236 +- (CNLiveUserInfoNavigationBar *)navigationBar {
  237 + if (!_navigationBar) {
  238 + _navigationBar = [[CNLiveUserInfoNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)];
  239 + _navigationBar.delegate = self;
  240 + _navigationBar.title.text = @"个人资料";
  241 + _navigationBar.right = nil;
  242 + }
  243 + return _navigationBar;
  244 +}
  245 +
229 246 - (NSMutableArray *)data {
230 247 if (!_data) {
231 248 _data = [NSMutableArray array];
... ...
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoNavigationBar.h 0 → 100644
  1 +//
  2 +// CNLiveUserInfoNavigationBar.m
  3 +// CNLiveMineModule
  4 +//
  5 +// Created by 153993236@qq.com on 11/12/2019.
  6 +// Copyright (c) 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +@class CNLiveUserInfoNavigationBar;
  13 +
  14 +@protocol CNLiveUserInfoNavigationBarDelegate <NSObject>
  15 +- (void)navigationBar:(CNLiveUserInfoNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents;
  16 +
  17 +@end
  18 +
  19 +@interface CNLiveUserInfoNavigationBar : UIView
  20 +@property (nonatomic, weak) id<CNLiveUserInfoNavigationBarDelegate> 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 +
  27 +@end
  28 +
  29 +NS_ASSUME_NONNULL_END
... ...
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoNavigationBar.m 0 → 100644
  1 +//
  2 +// CNLiveUserInfoNavigationBar.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 "CNLiveUserInfoNavigationBar.h"
  10 +#import "QMUIKit.h"
  11 +
  12 +@interface CNLiveUserInfoNavigationBar ()
  13 +
  14 +@end
  15 +
  16 +@implementation CNLiveUserInfoNavigationBar
  17 +static const NSInteger margin = 15;
  18 +
  19 +- (instancetype)initWithFrame:(CGRect)frame{
  20 + self = [super initWithFrame:frame];
  21 + if(self){
  22 + self.userInteractionEnabled = YES;
  23 + self.backgroundColor = [UIColor clearColor];
  24 + [self createSubViews];
  25 + }
  26 + return self;
  27 +}
  28 +
  29 +- (void)dealloc {
  30 + NSLog(@"CNLiveUserInfoNavigationBar -- dealloc");
  31 +}
  32 +
  33 +- (void)createSubViews {
  34 + [self addSubview:self.navView];
  35 + [self addSubview:self.left];
  36 + [self addSubview:self.title];
  37 + [self addSubview:self.right];
  38 +}
  39 +
  40 +/*
  41 + // Only override drawRect: if you perform custom drawing.
  42 + // An empty implementation adversely affects performance during animation.
  43 + - (void)drawRect:(CGRect)rect {
  44 + // Drawing code
  45 + }
  46 + */
  47 +
  48 +#pragma mark - 懒加载
  49 +- (UIView *)navView {
  50 + if (!_navView) {
  51 + _navView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, NavigationContentTop)];
  52 + _navView.backgroundColor = [UIColor clearColor];
  53 + }
  54 + return _navView;
  55 +}
  56 +
  57 +- (UIButton *)left {
  58 + if (!_left) {
  59 + _left= [UIButton buttonWithType:UIButtonTypeCustom];
  60 + _left.adjustsImageWhenHighlighted = NO;
  61 + _left.frame = CGRectMake(margin, StatusBarHeight, NavigationBarHeight, NavigationBarHeight);
  62 + UIImage *image = [self xw_getImageName:@"mine_back_black_b" bundleName:@"CNLiveMineModule" targetClass:[CNLiveUserInfoNavigationBar class]];
  63 + [_left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
  64 + [_left setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  65 + [_left addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
  66 + }
  67 + return _left;
  68 +}
  69 +
  70 +- (UILabel *)title {
  71 + if (!_title) {
  72 + _title = [[UILabel alloc] initWithFrame:CGRectMake(margin+NavigationBarHeight, StatusBarHeight, SCREEN_WIDTH-2*(margin+NavigationBarHeight), NavigationBarHeight)];
  73 + [_title setFont:[UIFont systemFontOfSize:18]];
  74 + _title.textColor = [UIColor blackColor];
  75 + _title.textAlignment = NSTextAlignmentCenter;
  76 + }
  77 + return _title;
  78 +}
  79 +
  80 +- (UIButton *)right {
  81 + if (!_right) {
  82 + _right = [UIButton buttonWithType:UIButtonTypeCustom];
  83 + _right.frame = CGRectMake(SCREEN_WIDTH-50-margin, StatusBarHeight, 50, NavigationBarHeight);
  84 + [_right setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
  85 + _right.adjustsImageWhenHighlighted = NO;
  86 + _right.titleLabel.font = [UIFont systemFontOfSize:15];
  87 + [_right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  88 + [_right addTarget:self action:@selector(rightDidClicked:) forControlEvents:UIControlEventTouchUpInside];
  89 + }
  90 + return _right;
  91 +}
  92 +
  93 +#pragma mark - 响应方法
  94 +- (void)goBack{
  95 + if (self.delegate && [self.delegate respondsToSelector:@selector(navigationBar:actionEvents:)]) {
  96 + [self.delegate navigationBar:self actionEvents:@"1"];
  97 + }
  98 +}
  99 +- (void)rightDidClicked:(UIButton *)btn{
  100 + if (self.delegate && [self.delegate respondsToSelector:@selector(navigationBar:actionEvents:)]) {
  101 + [self.delegate navigationBar:self actionEvents:@"2"];
  102 + }
  103 +}
  104 +
  105 +/**
  106 + * 创建图片
  107 + *
  108 + * @param imageName 图片名字
  109 + * @param bundleName 图片所在的bundle名字
  110 + * @param targetClass 类和bundle的同级目录
  111 + * @return 返回UIImage
  112 + */
  113 +- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{
  114 + NSBundle *bundle = [NSBundle bundleForClass:targetClass];
  115 + NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"];
  116 + NSBundle *targetBundle = [NSBundle bundleWithURL:url];
  117 + UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil];
  118 + return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
  119 +
  120 +}
  121 +
  122 +@end
... ...