zoukankan      html  css  js  c++  java
  • 实现支付宝的修改支付密码的功能

    先附一张做出的效果图吧

    这个是项目中钱包部分的功能,先说下页面的构建,我这里使用的是六个UITextField组成的密码框,这六个主要是显示部分,为了后面的显示方面,这里把这六个密码框的tag值依次设为1,2,3,4,5,6。

    代码中再写一个UITextField,把它隐藏掉,并调出键盘,来控制输入的内容,代码如下:

    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];

        self.textField.hidden = YES;

        self.textField.keyboardType = UIKeyboardTypeNumberPad;

        [self.textField becomeFirstResponder];

        [self.textField addTarget:self action:@selector(textChange:) forControlEvents:UIControlEventEditingChanged];

        [self.view addSubview:self.textField];

        

        for (int i = 0; i < 6; i++)

        {

            UITextField * pswTF = [self.view viewWithTag:i+1];

            pswTF.secureTextEntry = YES;

            pswTF.layer.borderColor = [[UIColor grayColor]CGColor];

            pswTF.layer.borderWidth = 1;

            pswTF.delegate = self;

        }

     当输入框的内容改变时,就调用方法,将输入的内容分散显示

    #pragma mark - 文本框内容改变

    - (void)textChange:(UITextField *)textField {

        NSString *password = textField.text;

        if (password.length > 6) {

            textField.text = [password substringToIndex:6];

            return;

        }

        

        for (int i = 0; i < 6; i++)

        {

            UITextField *pwdTextField= [self.view viewWithTag:i+1];

            if (i < password.length) {

                NSString *pwd = [password substringWithRange:NSMakeRange(i, 1)];

                pwdTextField.text = pwd;

            } else {

                pwdTextField.text = nil;

            }

            

        }

        if (password.length == 6)

        {

            [textField resignFirstResponder];//隐藏键盘

        }

    }

    当点击下一步时,这里对密码的复杂度做了判断,当不符合要求时需要将密码框的内容清空,重新输入

    -(void)clearPswTest

    {

        self.textField.text = @"";

        for (int i = 0; i < 6; i++)

        {

            UITextField *pwdTextField= [self.view viewWithTag:i+1];

            pwdTextField.text = @"";

        }

        [self.textField becomeFirstResponder];

    }

    这里只说下大概的处理思路,具体的demo请在这里下载查看。

    http://code.cocoachina.com/view/133653

  • 相关阅读:
    12.2 ROS NavFn全局规划源码解读_2
    12.1 ROS NavFn全局规划源码_1
    12 ROS Movebase主体源码解读
    11 ROS 动态参数调节
    10. ROS costmap代价地图
    无人驾驶汽车1: 基于Frenet优化轨迹的无人车动作规划方法
    VC下加载JPG/GIF/PNG图片的两种方法
    vc++加载透明png图片方法-GDI+和CImage两种
    供CImage类显示的半透明PNG文件处理方法
    使用MFC CImage类绘制PNG图片时遇到的问题
  • 原文地址:https://www.cnblogs.com/cui-cui/p/6138073.html
Copyright © 2011-2022 走看看