iOS开发—Swift实现支付密码弹窗

Swift实现支付密码弹窗

输入支付密码弹窗简单实现,类似支付宝。


主要代码文件

  • popPayPwdView//支付密码弹窗实现
  • CodeTextField//防止textField出现复制黏贴
使用方法:
    //需要使用支付弹窗
    @IBAction func inputPwdBtnPressed(sender: UIButton) {
        popPayView = popPayPwdView()
        popPayView!.delegate = self
        popPayView!.pop()
    }
    //支付密码
    var yourPayCode = "111111"
    //popPayDelegate、匹配支付密码,最好从服务端匹配支付密码
    func compareCode(payCode: String) {
        if payCode == yourPayCode {
            print("inputPwd successed")
            let con = UIViewController()
            con.title = "Successed"
            con.view.backgroundColor =           UIColor.redColor()
            self.navigationController?.pushViewController(con, animated: true)
        } else {
            if #available(iOS 8.0, *) {
                let alertController = UIAlertController(title: nil, message: "PassWord Error", preferredStyle: .Alert)
                let cancelAction = UIAlertAction(title: "OK", style: .Cancel) { (action) in

                }
                alertController.addAction(cancelAction)
                self.presentViewController(alertController, animated: true) {

                }
            } else {
                let errorAlertView = UIAlertView(title: "PassWord Error", message: "Please try again", delegate: self, cancelButtonTitle: "Ok")
                errorAlertView.show()
            }
        }
    }
  • 具体实现支付弹窗请移步git^.^
  • 实现中如有不足之处,欢迎大家留言^.^
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值