Skip to content

Commit

Permalink
完善验证码布局,抽离注册下一步view
Browse files Browse the repository at this point in the history
  • Loading branch information
18ronaldo committed Oct 27, 2017
1 parent d1e5e1b commit f445e70
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 1 deletion.
6 changes: 6 additions & 0 deletions MyShop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
7B7FBC561FA2D85900C984F3 /* WHRegisterInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7FBC551FA2D85900C984F3 /* WHRegisterInputView.m */; };
7B7FBC591FA2D87A00C984F3 /* WHThirdLoginView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7FBC581FA2D87A00C984F3 /* WHThirdLoginView.m */; };
7B7FBC611FA30A5100C984F3 /* WHRegisterNextViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7FBC601FA30A5100C984F3 /* WHRegisterNextViewController.m */; };
7B7FBC641FA32DB300C984F3 /* WHRegisterNextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B7FBC631FA32DB300C984F3 /* WHRegisterNextView.m */; };
7BFC6DAB1F9F000C006042AE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BFC6DAA1F9F000C006042AE /* main.m */; };
7BFC6DAE1F9F000C006042AE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BFC6DAD1F9F000C006042AE /* AppDelegate.m */; };
7BFC6DB61F9F000C006042AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7BFC6DB51F9F000C006042AE /* Assets.xcassets */; };
Expand Down Expand Up @@ -56,6 +57,8 @@
7B7FBC581FA2D87A00C984F3 /* WHThirdLoginView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WHThirdLoginView.m; sourceTree = "<group>"; };
7B7FBC5F1FA30A5100C984F3 /* WHRegisterNextViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WHRegisterNextViewController.h; sourceTree = "<group>"; };
7B7FBC601FA30A5100C984F3 /* WHRegisterNextViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WHRegisterNextViewController.m; sourceTree = "<group>"; };
7B7FBC621FA32DB300C984F3 /* WHRegisterNextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WHRegisterNextView.h; sourceTree = "<group>"; };
7B7FBC631FA32DB300C984F3 /* WHRegisterNextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WHRegisterNextView.m; sourceTree = "<group>"; };
7BFC6DA61F9F000C006042AE /* MyShop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MyShop.app; sourceTree = BUILT_PRODUCTS_DIR; };
7BFC6DAA1F9F000C006042AE /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
7BFC6DAC1F9F000C006042AE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -197,6 +200,8 @@
7B7FBC5E1FA30A0E00C984F3 /* view */ = {
isa = PBXGroup;
children = (
7B7FBC621FA32DB300C984F3 /* WHRegisterNextView.h */,
7B7FBC631FA32DB300C984F3 /* WHRegisterNextView.m */,
);
path = view;
sourceTree = "<group>";
Expand Down Expand Up @@ -617,6 +622,7 @@
7B7FBC491FA1FEED00C984F3 /* WHMyHeadView.m in Sources */,
7BFC6DAB1F9F000C006042AE /* main.m in Sources */,
7B7FBC561FA2D85900C984F3 /* WHRegisterInputView.m in Sources */,
7B7FBC641FA32DB300C984F3 /* WHRegisterNextView.m in Sources */,
7B7FBC461FA1FC2500C984F3 /* WHMyMessageTableView.m in Sources */,
7BFC6E131FA19126006042AE /* WHTimeViewController.m in Sources */,
);
Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions MyShop/注册/view/WHRegisterInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ - (UIButton *)nextBtn{
[_nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
_nextBtn.backgroundColor = RGB(229, 229, 229);
[_nextBtn setTitleColor:RGB(132, 132, 132) forState:UIControlStateNormal];
[_nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
_nextBtn.selected = NO;
_nextBtn.userInteractionEnabled = NO;
[_nextBtn addTarget:self action:@selector(pushNextViewController) forControlEvents:UIControlEventTouchUpInside];
}
Expand Down Expand Up @@ -163,19 +165,23 @@ - (void)userNameTextChangeText:(UITextField *)textField{
if (textField.text.length == 11 && _passwordText.text.length > 5) {
_nextBtn.backgroundColor = RGB(56, 165, 241);
_nextBtn.userInteractionEnabled = YES;
_nextBtn.selected = YES;
}else{
_nextBtn.backgroundColor = RGB(229, 229, 229);
_nextBtn.userInteractionEnabled = NO;
_nextBtn.selected = NO;
}
}
//密码输入框修改内容时调用的方法
- (void)passwordTextChangeText:(UITextField *)textField{
if (_userNameText.text.length == 11 && textField.text.length > 5) {
_nextBtn.backgroundColor = RGB(56, 165, 241);
_nextBtn.userInteractionEnabled = YES;
_nextBtn.selected = YES;
}else{
_nextBtn.backgroundColor = RGB(229, 229, 229);
_nextBtn.userInteractionEnabled = NO;
_nextBtn.selected = NO;
}
}
- (void)pushNextViewController{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,39 @@
//

#import "WHRegisterNextViewController.h"
#import "WHRegisterNextView.h"

@interface WHRegisterNextViewController ()

//注册下一步view
@property(nonatomic,strong) WHRegisterNextView *registerNextView;

@end

@implementation WHRegisterNextViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = mainColor;
self.edgesForExtendedLayout = 0;
self.title = @"验证手机号";

[self.view addSubview:self.registerNextView];
__weak typeof(self) weakSelf = self;
[_registerNextView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(weakSelf.view);
make.height.mas_equalTo(@150);
}];

WHLog(@"用户名和密码:%@",_userMessageDict);
// Do any additional setup after loading the view.

}

- (WHRegisterNextView *)registerNextView{
if (!_registerNextView) {
_registerNextView = [[WHRegisterNextView alloc] init];
}
return _registerNextView;
}

- (void)didReceiveMemoryWarning {
Expand Down
13 changes: 13 additions & 0 deletions MyShop/注册/下一步/view/WHRegisterNextView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// WHRegisterNextView.h
// MyShop
//
// Created by 王辉 on 2017/10/27.
// Copyright © 2017年 ronaldo. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface WHRegisterNextView : UIView

@end
154 changes: 154 additions & 0 deletions MyShop/注册/下一步/view/WHRegisterNextView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
//
// WHRegisterNextView.m
// MyShop
//
// Created by 王辉 on 2017/10/27.
// Copyright © 2017年 ronaldo. All rights reserved.
//

#import "WHRegisterNextView.h"

@interface WHRegisterNextView()<UITextFieldDelegate>

//提示验证码发送到哪个手机号码的label
@property(nonatomic,strong) UILabel *tishiLabel;
//背景label
@property(nonatomic,strong) UILabel *backLabel;
//验证码输入框
@property(nonatomic,strong) UITextField *codeText;
//显示倒计时button
@property(nonatomic,strong) UIButton *timeBtn;
//竖分割线
@property(nonatomic,strong) UILabel *lineLabel;
//注册button
@property(nonatomic,strong) UIButton *registerBtn;

@end

@implementation WHRegisterNextView

- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
[self addSubview:self.tishiLabel];
[self addSubview:self.backLabel];
[self addSubview:self.codeText];
[self addSubview:self.timeBtn];
[self addSubview:self.lineLabel];
[self addSubview:self.registerBtn];
}
return self;
}
-(void)layoutSubviews{
[super layoutSubviews];
__weak typeof(self) weakSelf = self;
[_tishiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.right.equalTo(weakSelf);
make.height.mas_equalTo(@35);
make.left.equalTo(weakSelf.mas_left).offset(15);
}];
[_backLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(@44);
make.top.equalTo(weakSelf.tishiLabel.mas_bottom);
make.left.equalTo(weakSelf.mas_left).offset(-1);
make.right.equalTo(weakSelf.mas_right).offset(1);
}];
[_codeText mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.equalTo(weakSelf.backLabel);
make.left.equalTo(weakSelf.backLabel.mas_left).offset(15);
make.right.equalTo(weakSelf.backLabel.mas_right).offset(VIEW_WIDTH - 120);
}];
[_timeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(100, 40));
make.centerY.equalTo(weakSelf.codeText.mas_centerY);
make.right.equalTo(weakSelf.mas_right);
}];
[_lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(1, 30));
make.centerY.equalTo(weakSelf.codeText.mas_centerY);
make.right.equalTo(weakSelf.timeBtn.mas_left).offset(-1);
}];
[_registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(weakSelf.codeText.mas_bottom).offset(15);
make.left.equalTo(weakSelf.mas_left).offset(16);
make.right.equalTo(weakSelf.mas_right).offset(-16);
make.height.mas_equalTo(@35);
}];
}

- (UILabel *)tishiLabel{
if (!_tishiLabel) {
_tishiLabel = [[UILabel alloc] init];
_tishiLabel.text = @"验证码已发送到 +86";
_tishiLabel.font = [UIFont systemFontOfSize:12.0];
}
return _tishiLabel;
}
- (UILabel *)backLabel{
if (!_backLabel) {
_backLabel = [[UILabel alloc] init];
_backLabel.backgroundColor = [UIColor whiteColor];
_backLabel.layer.borderColor = RGB(188, 188, 188).CGColor;
_backLabel.layer.borderWidth = 1;
}
return _backLabel;
}
- (UITextField *)codeText{
if (!_codeText) {
_codeText = [[UITextField alloc] init];
_codeText.delegate = self;
_codeText.placeholder = @"请输入验证码";
[_codeText addTarget:self action:@selector(codeTextChangeText:) forControlEvents:UIControlEventEditingChanged];
}
return _codeText;
}
- (UIButton *)timeBtn{
if (!_timeBtn) {
_timeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_timeBtn setTitle:@"30秒后重试" forState:UIControlStateNormal];
[_timeBtn setTitleColor:RGB(188, 188, 188) forState:UIControlStateNormal];
}
return _timeBtn;
}
- (UILabel *)lineLabel{
if (!_lineLabel) {
_lineLabel = [[UILabel alloc] init];
_lineLabel.backgroundColor = RGB(188, 188, 188);
}
return _lineLabel;
}
- (UIButton *)registerBtn{
if (!_registerBtn) {
_registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_registerBtn setTitle:@"注册" forState:UIControlStateNormal];
_registerBtn.backgroundColor = RGB(229, 229, 229);
_registerBtn.userInteractionEnabled = NO;
[_registerBtn setTitleColor:RGB(132, 132, 132) forState:UIControlStateNormal];
[_registerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
_registerBtn.selected = NO;
}
return _registerBtn;
}

- (void)codeTextChangeText:(UITextField *)textField{
if (textField.text.length == 6) {
_registerBtn.backgroundColor = RGB(56, 166, 241);
_registerBtn.userInteractionEnabled = YES;
_registerBtn.selected = YES;
}else{
_registerBtn.backgroundColor = RGB(229, 229, 229);
_registerBtn.userInteractionEnabled = NO;
_registerBtn.selected = NO;
}
}

#pragma mark - UITextFieldDelegate
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
if (range.location == 6) {
return NO;
}
return YES;
}


@end

0 comments on commit f445e70

Please sign in to comment.