| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- //
- // InputView.m
- // VclustersGemini
- //
- // Created by APPLE on 2019/6/10.
- // Copyright © 2019 APPLE. All rights reserved.
- //
- #import "InputViewForSMSCod.h"
- #import "iPhone.h"
- @implementation InputViewForSMSCod
- @synthesize delegate;
- @synthesize phoneNumInput;
- @synthesize smsInput;
- @synthesize smsCodeBtn;
- @synthesize phoneErrorTipsLabel;
- @synthesize smsErrorTipsLabel;
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:CGRectMake(0, 0, SCREEN_W, 44.f*3.f+2*30.f/2.f)];
-
- if (self){
- [self setBackgroundColor:[UIColor clearColor]];
- [self drawView];
- }
-
- return self;
- }
- - (void)drawView{
- CGFloat w_left_right = 37.f;
-
- /*电话号码输入框*/
- UIView *phoneNumInputBGView = [[UIView alloc] init];
- [phoneNumInputBGView.layer setCornerRadius:8.f/2.f];
- [phoneNumInputBGView setBackgroundColor:[UIColor clearColor]];
-
- /*电话号码输入框*/
- phoneNumInput = [[UITextField alloc] init];
- [phoneNumInput.layer setCornerRadius:8.f/2.f];
- [phoneNumInput setBackgroundColor:[UIColor clearColor]];
-
- NSString *placeholderStr = NSLocalizedString(@"log_phone_placeholderStr",nil);
- CGFloat fontSize = 14.f;
- CGFloat inputTextFieldH = 48.f;
- CGFloat inputTextFieldBGH = 68.f;
- NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
- style.alignment = NSTextAlignmentLeft;
-
- NSAttributedString *attri = nil;
- NSString *verphone = [iPhone phoneVersion];
-
- if ([verphone isEqualToString:@"10.3.3"]){
- attri = [[NSAttributedString alloc] initWithString:placeholderStr
- attributes:@{NSForegroundColorAttributeName:COLOR_PACEHOLDER,
- NSFontAttributeName:[UIFont systemFontOfSize:fontSize],
- NSBaselineOffsetAttributeName:[NSNumber numberWithFloat:-1.5],
- NSParagraphStyleAttributeName:style}];
- }else{
- attri = [[NSAttributedString alloc] initWithString:placeholderStr
- attributes:@{NSForegroundColorAttributeName:COLOR_PACEHOLDER,
- NSFontAttributeName:[UIFont systemFontOfSize:fontSize],
- NSParagraphStyleAttributeName:style}];
- }
- phoneNumInput.attributedPlaceholder = attri;
-
- [phoneNumInputBGView addSubview:phoneNumInput];
- [phoneNumInput mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0.f);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(inputTextFieldH);
- }];
- [phoneNumInput setTextColor:HW0A132BColor];
- [phoneNumInput setClearButtonMode:(UITextFieldViewModeWhileEditing)];
- [phoneNumInput setKeyboardType:(UIKeyboardTypeNumberPad)];
-
- /*下划线*/
- UIView *line0 = [[UIView alloc] init];
- [line0 setBackgroundColor:HWC1C9D6Color];
-
- [phoneNumInputBGView addSubview:line0];
- [line0 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(phoneNumInput.mas_bottom);
- make.left.mas_equalTo(0.f);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(1.f);
- }];
-
- /*提示语*/
- phoneErrorTipsLabel = [[UILabel alloc] init];
- [phoneErrorTipsLabel setText:NSLocalizedString(@"log_phone_error_tips",nil)];
- [phoneErrorTipsLabel setFont:[UIFont systemFontOfSize:12]];
- [phoneErrorTipsLabel setTextColor:HWDD4E4EColor];
- [phoneNumInputBGView addSubview:phoneErrorTipsLabel];
- [phoneErrorTipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(-2.f);
- make.left.mas_equalTo(0.f);
- make.right.mas_equalTo(0);
- }];
- [phoneErrorTipsLabel setHidden:YES];
-
- [self addSubview:phoneNumInputBGView];
- [phoneNumInputBGView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0.f);
- make.left.mas_equalTo(w_left_right);
- make.right.mas_equalTo(-w_left_right);
- make.height.mas_equalTo(inputTextFieldBGH);
- }];
-
- /*验证码输入框 验证码获取按钮*/
- /*计算验证码输入框 宽度 获取验证码按钮宽度*/
- UIView *smsInputBGView = [[UIView alloc] init];
- [smsInputBGView.layer setCornerRadius:8.f/2.f];
- [smsInputBGView setBackgroundColor:[UIColor clearColor]];
-
- CGFloat w_smsBtn = 67.f;
- smsInput = [[UITextField alloc] init];
- [smsInput.layer setCornerRadius:8.f/2.f];
- [smsInput setBackgroundColor:[UIColor clearColor]];
- [smsInput setTextColor:HW0A132BColor];
-
- NSString *placeholderStrForSms = NSLocalizedString(@"log_sms_placeholderStr",nil);
- NSMutableParagraphStyle *style2 = [[NSMutableParagraphStyle alloc] init];
- style2.alignment = NSTextAlignmentLeft;
-
- NSAttributedString *attri2 = nil;
-
- if ([verphone isEqualToString:@"10.3.3"]){
- attri2 = [[NSAttributedString alloc] initWithString:placeholderStrForSms
- attributes:@{NSForegroundColorAttributeName:COLOR_PACEHOLDER,
- NSFontAttributeName:[UIFont systemFontOfSize:fontSize],
- NSBaselineOffsetAttributeName:[NSNumber numberWithFloat:-1.5],
- NSParagraphStyleAttributeName:style2}];
- }else{
- attri2 = [[NSAttributedString alloc] initWithString:placeholderStrForSms
- attributes:@{NSForegroundColorAttributeName:COLOR_PACEHOLDER,
- NSFontAttributeName:[UIFont systemFontOfSize:fontSize],
- NSParagraphStyleAttributeName:style2}];
- }
- smsInput.attributedPlaceholder = attri2;
-
- [smsInputBGView addSubview:smsInput];
- [smsInput mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(-w_smsBtn);
- make.height.mas_equalTo(inputTextFieldH);
- }];
- [smsInput setClearButtonMode:(UITextFieldViewModeWhileEditing)];
- [smsInput setKeyboardType:(UIKeyboardTypeNumberPad)];
-
- /*获取验证码按钮*/
- smsCodeBtn = [[UIButton alloc] init];
- [smsCodeBtn setBackgroundColor:[UIColor clearColor]];
- [smsCodeBtn setTitle:NSLocalizedString(@"log_sms_get",nil) forState:(UIControlStateNormal)];
- [smsCodeBtn.titleLabel setFont:[UIFont systemFontOfSize:13.f]];
- [smsCodeBtn setTitleColor:COLOR_HEIGHT_BTN forState:(UIControlStateNormal)];
- [smsCodeBtn setTitleColor:COLOR_UNABLE_TITLE_BTN forState:(UIControlStateDisabled)];
- [smsCodeBtn addTarget:self action:@selector(smsCodeBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)];
- [smsCodeBtn.layer setCornerRadius:8.f/2.f];
- [smsInputBGView addSubview:smsCodeBtn];
-
- [smsCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self->smsInput.mas_right);
- make.top.equalTo(self->smsInput.mas_top);
- make.width.mas_equalTo(w_smsBtn);
- make.height.mas_equalTo(inputTextFieldH);
- }];
-
- /*下划线*/
- UIView *line1 = [[UIView alloc] init];
- [line1 setBackgroundColor:HWC1C9D6Color];
-
- [smsInputBGView addSubview:line1];
- [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(smsInput.mas_bottom);
- make.left.mas_equalTo(0.f);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(1.f);
- }];
-
- /*提示语*/
- smsErrorTipsLabel = [[UILabel alloc] init];
- [smsErrorTipsLabel setText:NSLocalizedString(@"log_sms_error_tips",nil)];
- [smsErrorTipsLabel setFont:[UIFont systemFontOfSize:12]];
- [smsErrorTipsLabel setTextColor:HWDD4E4EColor];
- [smsInputBGView addSubview:smsErrorTipsLabel];
- [smsErrorTipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(-2.f);
- make.left.mas_equalTo(0.f);
- make.right.mas_equalTo(0);
- }];
- [smsErrorTipsLabel setHidden:YES];
-
- [self addSubview:smsInputBGView];
- [smsInputBGView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(phoneNumInputBGView.mas_bottom);
- make.left.mas_equalTo(w_left_right);
- make.right.mas_equalTo(-w_left_right);
- make.height.mas_equalTo(inputTextFieldBGH);
- }];
- }
- - (void)smsCodeBtnPressed:(id)sender{
- if ([delegate respondsToSelector:@selector(smsCodeBtnBePressed:smsCodeInputView:)]){
- [delegate smsCodeBtnBePressed:sender smsCodeInputView:phoneNumInput];
- }
- }
- - (void)hiddenKeyboard{
- [self.phoneNumInput resignFirstResponder];
- [self.smsInput resignFirstResponder];
- }
- @end
|