iOS密码框的实现方式

Posted 旅途

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS密码框的实现方式相关的知识,希望对你有一定的参考价值。

说一下密码加密的实现方式
 
效果图:
 
 
CC05CAD0 C90F 46B8 9F5C 63B3FA27BB55
 
 
 
实现方式:
 
主要说一下密码框的实现,这个密码框中间的四个数字其实是4个 UITextField ,然后通过键盘删除键 和TextFiled 的协议shouldChangeCharactersInRange.来判断输入的位置,代码如下;
 
 
 
直接上代码:
 
//
//  IDSGameRoomSecretView.h
//
//  Created by levi.duan on 2017/7/18.
//  Copyright © 2017 Near. All rights reserved.
//

#import <UIKit/UIKit.h>
#import
"BaseViewController.h"

typedefvoid(^handleInputPasswordBlock)(NSString *password);

@interface IDSGameRoomSecretView : UIView

- (
instancetype)initWithPasswordCallBack:(handleInputPasswordBlock)passwordCallback;

/**
 
弹出说明视图
 */

- (
void)showInputSecretView;


@end
 
 
 
 
 
 
//
//  IDSGameRoomSecretView.m
//  Near
//
//  Created by levi.duan on 2017/7/18.
//  Copyright © 2017 Near. All rights reserved.
//

#import "IDSGameRoomSecretView.h"
#import
"PZXVerificationTextField.h"


@interfaceIDSGameRoomSecretView()<UIGestureRecognizerDelegate,UITextFieldDelegate,PZXTextFieldDelegate>

@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UILabel *subtitleLabel;
@property (nonatomic,strong) UITextField *secretTextField;
@property (nonatomic,strong) UIButton *gameRoomBtn;
@property (nonatomic, strong) UIView *secretRoomView;
@property (nonatomic, strong) NSMutableArray *textFieldArray;
@property (nonatomic , copy) handleInputPasswordBlock onHandlePasswordCallBack;



@end

@implementation IDSGameRoomSecretView

- (
instancetype)initWithPasswordCallBack:(handleInputPasswordBlock)passwordCallback
{
   
if (self = [superinit]) {
       
self.onHandlePasswordCallBack = passwordCallback;
    }
   
   
returnself;
}

- (
void)showInputSecretView
{

   
self.backgroundColor = [UIColorcolorWithRed:0green:0blue:0alpha:0.7];

    [[
AppDelegatemainWindow] addSubview:self];
    [
self.inputViewbecomeFirstResponder];
   
   
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
   
   
UITapGestureRecognizer *selfRecognizer = [[UITapGestureRecognizeralloc] initWithTarget:selfaction:@selector(removeView)];
   
self.userInteractionEnabled = YES;
    [
selfaddGestureRecognizer:selfRecognizer];
    selfRecognizer.
delegate = self;
   
   
self.secretRoomView = [[UIViewalloc] initWithFrame:CGRectMake(0, 0, 510/2, 380/2)];
   
self.secretRoomView.centerY = SCREEN_HEIGHT/2;
   
self.secretRoomView.centerX = SCREEN_WIDTH/2;
   
self.secretRoomView.backgroundColor = [UIColorwhiteColor];
   
   
self.secretRoomView.centerY = SCREEN_HEIGHT/2-50;
 
   

   
_titleLabel = [[UILabelalloc] initWithFrame:CGRectMake(0, 50/2, 0, 0)];
   
_titleLabel.text = @"房间已加锁";
   
_titleLabel.textColor = NF_Color_C3;
   
_titleLabel.font = [UIFontsystemFontOfSize:Near_Final_Font_T6];
    [
_titleLabelsizeToFit];
   
_titleLabel.centerX = self.secretRoomView.frame.size.width/2;
    [
self.secretRoomViewaddSubview:_titleLabel];
   
   
_subtitleLabel = [[UILabelalloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(self.titleLabel.frame)+10, 0, 0)];
   
_subtitleLabel.text = @"输入房间密码";
   
_subtitleLabel.textColor = NF_Color_C10;
   
_subtitleLabel.font = [UIFontsystemFontOfSize:Near_Final_Font_T9];
    [
_subtitleLabelsizeToFit];
   
_subtitleLabel.centerX = self.secretRoomView.frame.size.width/2;
    [
self.secretRoomViewaddSubview:_subtitleLabel];
   
   
self.textFiel

以上是关于iOS密码框的实现方式的主要内容,如果未能解决你的问题,请参考以下文章

Android注解方式实现表单校验

未解决的问题,登录163邮箱http://mail.163.com/,用xpath的方式定位密码输入框的时候,总是报找不到该元素

#密码框

iOS: 悬浮的条件筛选下拉框的使用

标签(表的单元素)

以编程方式删除/检查 iOS 密码